Handle nil and different types in stateData

This commit is contained in:
Ken-Håvard Lieng 2020-05-16 02:33:38 +02:00
parent 4b8491cf99
commit 75c9560dfb

View File

@ -228,15 +228,24 @@ func (s *stateData) Set(key string, value interface{}) {
} }
func (s *stateData) String(key string) string { func (s *stateData) String(key string) string {
return s.Get(key).(string) if v, ok := s.Get(key).(string); ok {
return v
}
return ""
} }
func (s *stateData) Int(key string) int { func (s *stateData) Int(key string) int {
return s.Get(key).(int) if v, ok := s.Get(key).(int); ok {
return v
}
return 0
} }
func (s *stateData) Bool(key string) bool { func (s *stateData) Bool(key string) bool {
return s.Get(key).(bool) if v, ok := s.Get(key).(bool); ok {
return v
}
return false
} }
type stateStore struct { type stateStore struct {