From 9f60b036108d0c1901a49e8a7d9857adbf451218 Mon Sep 17 00:00:00 2001 From: Rob Pike Date: Mon, 19 Oct 2009 10:34:00 -0700 Subject: [PATCH] address leftover post-submit comments about embedding R=rsc DELTA=11 (9 added, 0 deleted, 2 changed) OCL=35872 CL=35872 --- doc/effective_go.html | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/doc/effective_go.html b/doc/effective_go.html index 46b105a06b..0efd224a76 100644 --- a/doc/effective_go.html +++ b/doc/effective_go.html @@ -1799,6 +1799,15 @@ log to a Job: job.Log("starting now...");

+The Logger is a regular field of the struct and we can initialize +it in the usual way. +

+
+func NewJob(command string, logger *log.Logger) *Job {
+	return &Job{command, logger}
+}
+
+

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 *log.Logger of a Job variable job, @@ -1806,8 +1815,8 @@ we would write job.Logger. This would be useful if we wanted to refine the methods of Logger.

-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));
 }
 

-- 2.50.0