mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-06 07:57:35 +00:00
pkg/util/goroutinemap: apply idiomatic Go cleanups
Package goroutinemap can be structurally simplified to be more idiomatic, concise, and free of error potential. No structural changes are made. It is unconventional declare `sync.Mutex` directly as a pointerized field in a parent structure. The `sync.Mutex` operates on pointer receivers of itself; and by relying on that, the types that contain those fields can be safely constructed using https://golang.org/ref/spec#The_zero_value. The duration constants are already of type `time.Duration`, so re-declaring that is redundant.
This commit is contained in:
@@ -65,9 +65,8 @@ func NewNestedPendingOperations(exponentialBackOffOnError bool) NestedPendingOpe
|
||||
g := &nestedPendingOperations{
|
||||
operations: []operation{},
|
||||
exponentialBackOffOnError: exponentialBackOffOnError,
|
||||
lock: &sync.Mutex{},
|
||||
}
|
||||
g.cond = sync.NewCond(g.lock)
|
||||
g.cond = sync.NewCond(&g.lock)
|
||||
return g
|
||||
}
|
||||
|
||||
@@ -75,7 +74,7 @@ type nestedPendingOperations struct {
|
||||
operations []operation
|
||||
exponentialBackOffOnError bool
|
||||
cond *sync.Cond
|
||||
lock *sync.Mutex
|
||||
lock sync.Mutex
|
||||
}
|
||||
|
||||
type operation struct {
|
||||
|
||||
Reference in New Issue
Block a user