a first version of obisummary

Former-commit-id: cca1019d82a14a322f46a20890b996b5c7491d41
This commit is contained in:
2023-11-09 22:33:06 +02:00
parent a96ecb4837
commit 5ea2b8afcf
7 changed files with 378 additions and 30 deletions

View File

@ -148,6 +148,27 @@ func InterfaceToIntMap(i interface{}) (val map[string]int, err error) {
return
}
func InterfaceToStringMap(i interface{}) (val map[string]string, err error) {
err = nil
switch i := i.(type) {
case map[string]string:
val = i
case map[string]interface{}:
val = make(map[string]string, len(i))
for k, v := range i {
val[k], err = InterfaceToString(v)
if err != nil {
return
}
}
default:
err = &NotAMapInt{"value attribute cannot be casted to a map[string]int"}
}
return
}
// NotABoolean defines a new type of Error : "NotAMapInt"
type NotAMapFloat64 struct {
message string