You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
582 B
Go
38 lines
582 B
Go
package starmap
|
|
|
|
import (
|
|
"errors"
|
|
)
|
|
|
|
type StarMap interface {
|
|
GetName() string
|
|
}
|
|
|
|
type StarMapSample struct{}
|
|
|
|
func (sample StarMapSample) GetName() string {
|
|
return "starsample"
|
|
}
|
|
|
|
func GetMap(value StarMap) error {
|
|
kvmuPro.RLock()
|
|
defer kvmuPro.RUnlock()
|
|
value, ok := kvMapPro[value.GetName()]
|
|
if !ok {
|
|
return errors.New("key not exists")
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func StoreMap(value StarMap) error {
|
|
kvmuPro.Lock()
|
|
defer kvmuPro.Unlock()
|
|
kvMapPro[value.GetName()] = value
|
|
return nil
|
|
}
|
|
|
|
func DeleteMap(value StarMap) error {
|
|
delete(kvMapPro, value.GetName())
|
|
return nil
|
|
}
|