From b669212821c34d92d89c098f10e70dd5282bf81a Mon Sep 17 00:00:00 2001 From: andronache Date: Tue, 10 Nov 2020 11:25:11 +0200 Subject: [PATCH] Removed unused functions from utils package --- utils/struct.go | 32 -------------------------------- utils/struct_test.go | 20 -------------------- 2 files changed, 52 deletions(-) diff --git a/utils/struct.go b/utils/struct.go index 81d17f946..fc721476b 100644 --- a/utils/struct.go +++ b/utils/struct.go @@ -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) diff --git a/utils/struct_test.go b/utils/struct_test.go index 9710d9590..12587b818 100644 --- a/utils/struct_test.go +++ b/utils/struct_test.go @@ -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",