summaryrefslogtreecommitdiff
path: root/doc/effective_go.html
diff options
context:
space:
mode:
Diffstat (limited to 'doc/effective_go.html')
-rw-r--r--doc/effective_go.html17
1 files changed, 12 insertions, 5 deletions
diff --git a/doc/effective_go.html b/doc/effective_go.html
index 972772d33..2ecef44f4 100644
--- a/doc/effective_go.html
+++ b/doc/effective_go.html
@@ -233,9 +233,9 @@ Since the whole declaration is presented, such a comment can often be perfunctor
<pre>
// Error codes returned by failures to parse an expression.
var (
- ErrInternal = os.NewError("internal error")
- ErrUnmatchedLpar = os.NewError("unmatched '('")
- ErrUnmatchedRpar = os.NewError("unmatched ')'")
+ ErrInternal = os.NewError("regexp: internal error")
+ ErrUnmatchedLpar = os.NewError("regexp: unmatched '('")
+ ErrUnmatchedRpar = os.NewError("regexp: unmatched ')'")
...
)
</pre>
@@ -350,7 +350,7 @@ Both names read well in practice:
<pre>
owner := obj.Owner()
if owner != user {
- obj.SetOwner(user)
+ obj.SetOwner(user)
}
</pre>
@@ -2245,7 +2245,7 @@ we would write <code>job.Logger</code>.
This would be useful if we wanted to refine the methods of <code>Logger</code>.
</p>
<pre>
-func (job *Job) Logf(format string, args ...) {
+func (job *Job) Logf(format string, args ...interface{}) {
job.Logger.Logf("%q: %s", job.Command, fmt.Sprintf(format, args))
}
</pre>
@@ -2674,6 +2674,13 @@ it is much more informative than the plain
</p>
<p>
+When feasible, error strings should identify their origin, such as by having
+a prefix naming the package that generated the error. For example, in package
+image, the string representation for a decoding error due to an unknown format
+is "image: unknown format".
+</p>
+
+<p>
Callers that care about the precise error details can
use a type switch or a type assertion to look for specific
errors and extract details. For <code>PathErrors</code>