Use pointer receiver in stateData

This commit is contained in:
Ken-Håvard Lieng 2019-01-23 08:20:16 +01:00
parent 24b26aa85f
commit 5e674254f0

View File

@ -236,28 +236,28 @@ type stateData struct {
lock sync.Mutex lock sync.Mutex
} }
func (s stateData) Get(key string) interface{} { func (s *stateData) Get(key string) interface{} {
s.lock.Lock() s.lock.Lock()
v := s.m[key] v := s.m[key]
s.lock.Unlock() s.lock.Unlock()
return v return v
} }
func (s stateData) Set(key string, value interface{}) { func (s *stateData) Set(key string, value interface{}) {
s.lock.Lock() s.lock.Lock()
s.m[key] = value s.m[key] = value
s.lock.Unlock() s.lock.Unlock()
} }
func (s stateData) String(key string) string { func (s *stateData) String(key string) string {
return s.Get(key).(string) return s.Get(key).(string)
} }
func (s stateData) Int(key string) int { func (s *stateData) Int(key string) int {
return s.Get(key).(int) return s.Get(key).(int)
} }
func (s stateData) Bool(key string) bool { func (s *stateData) Bool(key string) bool {
return s.Get(key).(bool) return s.Get(key).(bool)
} }