mirror of
https://github.com/scratchfoundation/golangci-lint.git
synced 2025-08-12 22:38:46 -04:00
30 lines
509 B
Go
30 lines
509 B
Go
package load
|
|
|
|
import (
|
|
"sync"
|
|
|
|
"golang.org/x/tools/go/packages"
|
|
)
|
|
|
|
type Guard struct {
|
|
loadMutexes map[*packages.Package]*sync.Mutex
|
|
mutex sync.Mutex
|
|
}
|
|
|
|
func NewGuard() *Guard {
|
|
return &Guard{
|
|
loadMutexes: map[*packages.Package]*sync.Mutex{},
|
|
}
|
|
}
|
|
|
|
func (g *Guard) AddMutexForPkg(pkg *packages.Package) {
|
|
g.loadMutexes[pkg] = &sync.Mutex{}
|
|
}
|
|
|
|
func (g *Guard) MutexForPkg(pkg *packages.Package) *sync.Mutex {
|
|
return g.loadMutexes[pkg]
|
|
}
|
|
|
|
func (g *Guard) Mutex() *sync.Mutex {
|
|
return &g.mutex
|
|
}
|