forked from suddutt1/fabricnetgenerator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.go
44 lines (41 loc) · 823 Bytes
/
utils.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package main
import (
"fmt"
"strconv"
)
func getMap(element interface{}) map[string]interface{} {
retMap, ok := element.(map[string]interface{})
if ok == true {
return retMap
}
return nil
}
func getString(element interface{}) string {
retString, ok := element.(string)
if ok == true {
return retString
}
return ""
}
func getNumber(element interface{}) int {
s := fmt.Sprintf("%v", element)
retString, err := strconv.Atoi(s)
if err == nil {
return retString
}
return 0
}
func getBoolean(element interface{}) bool {
retString, ok := element.(string)
if ok == true {
retBool, inValid := strconv.ParseBool(retString)
if inValid == nil {
return retBool
}
}
return false
}
func ifExists(mapToCheck map[string]interface{}, attribute string) bool {
_, ok := mapToCheck[attribute]
return ok
}