Update linter
This commit is contained in:
parent
f12c27aa7c
commit
328611c619
157 changed files with 489 additions and 508 deletions
|
@ -4,25 +4,25 @@ import (
|
|||
"sync"
|
||||
)
|
||||
|
||||
// Safe contains a thread-safe value
|
||||
// Safe contains a thread-safe value.
|
||||
type Safe struct {
|
||||
value interface{}
|
||||
lock sync.RWMutex
|
||||
}
|
||||
|
||||
// New create a new Safe instance given a value
|
||||
// New create a new Safe instance given a value.
|
||||
func New(value interface{}) *Safe {
|
||||
return &Safe{value: value, lock: sync.RWMutex{}}
|
||||
}
|
||||
|
||||
// Get returns the value
|
||||
// Get returns the value.
|
||||
func (s *Safe) Get() interface{} {
|
||||
s.lock.RLock()
|
||||
defer s.lock.RUnlock()
|
||||
return s.value
|
||||
}
|
||||
|
||||
// Set sets a new value
|
||||
// Set sets a new value.
|
||||
func (s *Safe) Set(value interface{}) {
|
||||
s.lock.Lock()
|
||||
defer s.lock.Unlock()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue