Debian Codegraph @

go/analysis/passes/copylock/testdata/src/unfortunate/local_go123.go

raw symbols SCIP
1 // Copyright 2024 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
5 //go:build !go1.24
6
7 package unfortunate
8
9 import "sync"
10
11 // TODO: Unfortunate cases
12
13 // Non-ideal error message:
14 // Since we're looking for Lock methods, sync.Once's underlying
15 // sync.Mutex gets called out, but without any reference to the sync.Once.
16 type LocalOnce sync.Once
17
18 func (LocalOnce) Bad() {} // want `Bad passes lock by value: unfortunate.LocalOnce contains sync.\b.*`
19
20 // False negative:
21 // LocalMutex doesn't have a Lock method.
22 // Nevertheless, it is probably a bad idea to pass it by value.
23 type LocalMutex sync.Mutex
24
25 func (LocalMutex) Bad() {} // WANTED: An error here :(