~ubuntu-branches/ubuntu/vivid/golang/vivid

« back to all changes in this revision

Viewing changes to doc/effective_go.html

  • Committer: Bazaar Package Importer
  • Author(s): Ondřej Surý
  • Date: 2011-08-03 17:04:59 UTC
  • mfrom: (14.1.2 sid)
  • Revision ID: james.westby@ubuntu.com-20110803170459-wzd99m3567y80ila
Tags: 1:59-1
* Imported Upstream version 59
* Refresh patches to a new release
* Fix FTBFS on ARM (Closes: #634270)
* Update version.bash to work with Debian packaging and not hg
  repository

Show diffs side-by-side

added added

removed removed

Lines of Context:
233
233
<pre>
234
234
// Error codes returned by failures to parse an expression.
235
235
var (
236
 
    ErrInternal      = os.NewError("internal error")
237
 
    ErrUnmatchedLpar = os.NewError("unmatched '('")
238
 
    ErrUnmatchedRpar = os.NewError("unmatched ')'")
 
236
    ErrInternal      = os.NewError("regexp: internal error")
 
237
    ErrUnmatchedLpar = os.NewError("regexp: unmatched '('")
 
238
    ErrUnmatchedRpar = os.NewError("regexp: unmatched ')'")
239
239
    ...
240
240
)
241
241
</pre>
350
350
<pre>
351
351
owner := obj.Owner()
352
352
if owner != user {
353
 
        obj.SetOwner(user)
 
353
    obj.SetOwner(user)
354
354
}
355
355
</pre>
356
356
 
2245
2245
This would be useful if we wanted to refine the methods of <code>Logger</code>.
2246
2246
</p>
2247
2247
<pre>
2248
 
func (job *Job) Logf(format string, args ...) {
 
2248
func (job *Job) Logf(format string, args ...interface{}) {
2249
2249
    job.Logger.Logf("%q: %s", job.Command, fmt.Sprintf(format, args))
2250
2250
}
2251
2251
</pre>
2674
2674
</p>
2675
2675
 
2676
2676
<p>
 
2677
When feasible, error strings should identify their origin, such as by having
 
2678
a prefix naming the package that generated the error.  For example, in package
 
2679
image, the string representation for a decoding error due to an unknown format
 
2680
is "image: unknown format".
 
2681
</p>
 
2682
 
 
2683
<p>
2677
2684
Callers that care about the precise error details can
2678
2685
use a type switch or a type assertion to look for specific
2679
2686
errors and extract details.  For <code>PathErrors</code>