1
0
mirror of https://github.com/golang/go synced 2024-11-25 02:17:57 -07:00

address leftover post-submit comments about embedding

R=rsc
DELTA=11  (9 added, 0 deleted, 2 changed)
OCL=35872
CL=35872
This commit is contained in:
Rob Pike 2009-10-19 10:34:00 -07:00
parent f00be0caee
commit 9f60b03610

View File

@ -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>.
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>