mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-22 07:38:45 +05:00
Added FieldAsInterface for EventCost
This commit is contained in:
committed by
Dan Christian Bogos
parent
2f8b7dc53e
commit
ff5f5f2d21
@@ -892,3 +892,23 @@ func CastRPCErr(err error) error {
|
||||
func RandomInteger(min, max int) int {
|
||||
return math_rand.Intn(max-min) + min
|
||||
}
|
||||
|
||||
// GetPathIndex returns the path and index if index present
|
||||
// path[index]=>path,index
|
||||
// path=>path,nil
|
||||
func GetPathIndex(spath string) (opath string, idx *int) {
|
||||
idxStart := strings.Index(spath, IdxStart)
|
||||
if idxStart == -1 || !strings.HasSuffix(spath, IdxEnd) {
|
||||
return spath, nil
|
||||
}
|
||||
slctr := spath[idxStart+1 : len(spath)-1]
|
||||
opath = spath[:idxStart]
|
||||
// if strings.HasPrefix(slctr, DynamicDataPrefix) {
|
||||
// return
|
||||
// }
|
||||
idxVal, err := strconv.Atoi(slctr)
|
||||
if err != nil {
|
||||
return spath, nil
|
||||
}
|
||||
return opath, &idxVal
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user