copylock.go 333 B

123456789101112131415
  1. // Copyright 2018 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. package copylock
  5. import "sync"
  6. func BadFunc() {
  7. var x *sync.Mutex
  8. p := x
  9. var y sync.Mutex
  10. p = &y
  11. *p = *x // ERROR "assignment copies lock value to \*p: sync.Mutex"
  12. }