Commit 9f60b036 authored by Rob Pike's avatar Rob Pike

address leftover post-submit comments about embedding

R=rsc
DELTA=11  (9 added, 0 deleted, 2 changed)
OCL=35872
CL=35872
parent f00be0ca
...@@ -1799,6 +1799,15 @@ log to a <code>Job</code>: ...@@ -1799,6 +1799,15 @@ log to a <code>Job</code>:
job.Log("starting now..."); job.Log("starting now...");
</pre> </pre>
<p> <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, 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 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>, <code>*log.Logger</code> of a <code>Job</code> variable <code>job</code>,
...@@ -1806,8 +1815,8 @@ we would write <code>job.Logger</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>. This would be useful if we wanted to refine the methods of <code>Logger</code>.
</p> </p>
<pre> <pre>
func (job *Job) Logf(format string, v ...) { func (job *Job) Logf(format string, args ...) {
job.Logger.Logf(fmt.Sprintf("%q: %s", job.command, format), v); job.Logger.Logf("%q: %s", job.Command, fmt.Sprintf(format, args));
} }
</pre> </pre>
<p> <p>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment