]> Cypherpunks repositories - gostls13.git/commitdiff
address leftover post-submit comments about embedding
authorRob Pike <r@golang.org>
Mon, 19 Oct 2009 17:34:00 +0000 (10:34 -0700)
committerRob Pike <r@golang.org>
Mon, 19 Oct 2009 17:34:00 +0000 (10:34 -0700)
R=rsc
DELTA=11  (9 added, 0 deleted, 2 changed)
OCL=35872
CL=35872

doc/effective_go.html

index 46b105a06b60ed2b3881a08835a35855901234ef..0efd224a768e73e5f23d2634fbfb2f68be9c0907 100644 (file)
@@ -1799,6 +1799,15 @@ log to a <code>Job</code>:
 job.Log("starting now...");
 </pre>
 <p>
+The <code>Logger</code> is a regular field of the struct and we can initialize
+it in the usual way.
+</p>
+<pre>
+func NewJob(command string, logger *log.Logger) *Job {
+       return &amp;Job{command, logger}
+}
+</pre>
+<p>
 If we need to refer to an embedded field directly, the type name of the field,
 ignoring the package qualifier, serves as a field name.  If we needed to access the
 <code>*log.Logger</code> of a <code>Job</code> variable <code>job</code>,
@@ -1806,8 +1815,8 @@ 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, v ...) {
-       job.Logger.Logf(fmt.Sprintf("%q: %s", job.command, format), v);
+func (job *Job) Logf(format string, args ...) {
+       job.Logger.Logf("%q: %s", job.Command, fmt.Sprintf(format, args));
 }
 </pre>
 <p>