Skip to content

Instantly share code, notes, and snippets.

@davecheney
Created April 7, 2016 11:08
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davecheney/0b8e80c62949b42112c942d4fad65d98 to your computer and use it in GitHub Desktop.
Save davecheney/0b8e80c62949b42112c942d4fad65d98 to your computer and use it in GitHub Desktop.
Diffy McDiffface
diff --git a/src/errors/errors.go b/src/errors/errors.go
index b8a4692..ba1e239 100644
--- a/src/errors/errors.go
+++ b/src/errors/errors.go
@@ -10,6 +10,10 @@ func New(text string) error {
return &errorString{text}
}
+type Error string
+
+func (e Error) Error() string { return string(e) }
+
// errorString is a trivial implementation of error.
type errorString struct {
s string
diff --git a/src/io/io.go b/src/io/io.go
index 23401da..12e5d2e 100644
--- a/src/io/io.go
+++ b/src/io/io.go
@@ -35,7 +35,7 @@ var ErrShortBuffer = errors.New("short buffer")
// If the EOF occurs unexpectedly in a structured data stream,
// the appropriate error is either ErrUnexpectedEOF or some other error
// giving more detail.
-var EOF = errors.New("EOF")
+const EOF = errors.Error("EOF")
// ErrUnexpectedEOF means that EOF was encountered in the
// middle of reading a fixed-size block or data structure.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment