matterbridge/vendor/github.com/philippgille/gokv/util/util.go
Yousef Mansy c0f5d0c5f7 Add persistent message map
Resolves #541
2023-03-01 01:39:23 -08:00

30 lines
588 B
Go

package util
import (
"errors"
)
// CheckKeyAndValue returns an error if k == "" or if v == nil
func CheckKeyAndValue(k string, v interface{}) error {
if err := CheckKey(k); err != nil {
return err
}
return CheckVal(v)
}
// CheckKey returns an error if k == ""
func CheckKey(k string) error {
if k == "" {
return errors.New("The passed key is an empty string, which is invalid")
}
return nil
}
// CheckVal returns an error if v == nil
func CheckVal(v interface{}) error {
if v == nil {
return errors.New("The passed value is nil, which is not allowed")
}
return nil
}