mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Removed unused functions from utils package
This commit is contained in:
committed by
Dan Christian Bogos
parent
4d59d014e6
commit
b669212821
@@ -90,38 +90,6 @@ func MissingMapFields(s map[string]interface{}, mandatories []string) []string {
|
||||
return missing
|
||||
}
|
||||
|
||||
// Converts a struct to map
|
||||
/*func StrucToMap(s interface{}) map[string]interface{} {
|
||||
mp := make(map[string]interface{})
|
||||
for i := 0; i < reflect.ValueOf(s).Elem().NumField(); i++ {
|
||||
fld := reflect.ValueOf(s).Elem().Field(i)
|
||||
switch fld.Kind() {
|
||||
case reflect.Bool:
|
||||
mp[reflect.TypeOf(s).Elem().Field(i).Name] = fld.Bool()
|
||||
case reflect.Int:
|
||||
mp[reflect.TypeOf(s).Elem().Field(i).Name] = fld.Int()
|
||||
case reflect.String:
|
||||
mp[reflect.TypeOf(s).Elem().Field(i).Name] = fld.String()
|
||||
}
|
||||
}
|
||||
return mp
|
||||
}*/
|
||||
|
||||
// Converts a struct to map[string]interface{}
|
||||
func ToMapMapStringInterface(in interface{}) map[string]interface{} { // Got error and it is not used anywhere
|
||||
out := make(map[string]interface{})
|
||||
|
||||
v := reflect.ValueOf(in)
|
||||
if v.Kind() == reflect.Ptr {
|
||||
v = v.Elem()
|
||||
}
|
||||
typ := reflect.TypeOf(in)
|
||||
for i := 0; i < v.NumField(); i++ {
|
||||
out[typ.Field(i).Name] = v.Field(i).Interface()
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// Converts a struct to map[string]string
|
||||
func ToMapStringString(in interface{}) map[string]string {
|
||||
out := make(map[string]string)
|
||||
|
||||
@@ -256,26 +256,6 @@ func TestNonemptyStructFields(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
func TestToMapMapStringInterface(t *testing.T) {
|
||||
var attr = struct {
|
||||
Tenant string
|
||||
Direction bool
|
||||
Account string
|
||||
Type string
|
||||
}{"bevoip.eu", true, "testaccount", META_PREPAID}
|
||||
mapStruct := ToMapMapStringInterface(&attr)
|
||||
expMapStruct := map[string]interface{}{
|
||||
"Tenant": "bevoip.eu",
|
||||
"Direction": true,
|
||||
"Account": "testaccount",
|
||||
"Type": META_PREPAID,
|
||||
}
|
||||
if !reflect.DeepEqual(expMapStruct, mapStruct) {
|
||||
t.Errorf("expecting: %+v, received: %+v", expMapStruct, mapStruct)
|
||||
}
|
||||
}*/
|
||||
|
||||
func TestMissingMapFields(t *testing.T) {
|
||||
var attr = map[string]interface{}{
|
||||
Tenant: "cgrates.org",
|
||||
|
||||
Reference in New Issue
Block a user