title: How to log a struct with a mutex
body: <p>I have a struct in Go with a mutex:</p>
  
  <pre><code>package main
  
  import (
      "fmt"
      "sync"
  )
  
  type foo struct {
      sync.Mutex
      lastID       uint64
      nameToID map[string]uint64
  }
  
  func main() {
      fmt.Println("Hello, playground")
      foo2 := foo{lastID: 0,nameToID: map[string]uint64{"name":0}}
      fmt.Println(foo2) 
  }
  
  
  </code></pre>
  
  <p>Above gives a go vet warning (<a href="https://play.golang.org/p/J0NFgBvSGJC" rel="nofollow noreferrer">https://play.golang.org/p/J0NFgBvSGJC</a>) :</p>
  
  <pre><code>./prog.go:17:14: call of fmt.Println copies lock value: play.foo
  </code></pre>
  
  <p>I saw a related github issue <a href="https://github.com/golang/go/issues/13675" rel="nofollow noreferrer">https://github.com/golang/go/issues/13675</a> and understand the need of this warning in general to warn about copying locks. 
  I can workaround above by creating a custom string method omitting the lock. 
  However - since structs with mutexes seem widespread, I am wondering if there is a better/idiomatic way to log structs containing mutexes in Go?</p>