github.com/sean-/go@v0.0.0-20151219100004-97f854cd7bb6/src/cmd/vet/testdata/copylock.go (about) 1 package testdata 2 3 import "sync" 4 5 func OkFunc() { 6 var x *sync.Mutex 7 p := x 8 var y sync.Mutex 9 p = &y 10 } 11 12 type Tlock struct { 13 once sync.Once 14 } 15 16 func BadFunc() { 17 var x *sync.Mutex 18 p := x 19 var y sync.Mutex 20 p = &y 21 *p = *x // ERROR "assignment copies lock value to \*p: sync.Mutex" 22 23 var t Tlock 24 var tp *Tlock 25 tp = &t 26 *tp = t // ERROR "assignment copies lock value to \*tp: testdata.Tlock contains sync.Once contains sync.Mutex" 27 t = *tp // ERROR "assignment copies lock value to t: testdata.Tlock contains sync.Once contains sync.Mutex" 28 }