mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Add new type in utils MapSubsystemIDs
This commit is contained in:
committed by
Dan Christian Bogos
parent
a246124cc9
commit
763e030f03
21
utils/map.go
21
utils/map.go
@@ -247,3 +247,24 @@ func MapStringToInt64(in map[string]string) (out map[string]int64, err error) {
|
||||
}
|
||||
return mapout, nil
|
||||
}
|
||||
|
||||
func MapSubsystemIDsFromSlice(s []string) (MapSubsystemIDs, error) {
|
||||
result := make(MapSubsystemIDs, len(s))
|
||||
for _, v := range s {
|
||||
subsystemWithIDs := strings.Split(v, InInFieldSep)
|
||||
result[subsystemWithIDs[0]] = []string{}
|
||||
if len(subsystemWithIDs) == 2 {
|
||||
result[subsystemWithIDs[0]] = strings.Split(subsystemWithIDs[1], INFIELD_SEP)
|
||||
} else if len(subsystemWithIDs) > 2 {
|
||||
return nil, ErrUnsupportedFormat
|
||||
}
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
type MapSubsystemIDs map[string][]string
|
||||
|
||||
func (msIDs MapSubsystemIDs) HasKey(key string) (has bool) {
|
||||
_, has = msIDs[key]
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user