-
Notifications
You must be signed in to change notification settings - Fork 0
/
kConf.go
42 lines (34 loc) · 798 Bytes
/
kConf.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
package kConf
import (
"fmt"
"github.com/tidwall/gjson"
)
var config_DATA_BYTE []byte
/*
*InitDir
*path : file path
*/
func SetFiePath(path string) {
databyte,err := GetFileContentWithPath(path)
if err != nil {
fmt.Println("config file open error: ",err.Error())
return
}
config_DATA_BYTE = databyte
}
func GetConfString(jsonpath string)string{
result := gjson.GetBytes(config_DATA_BYTE,jsonpath)
return result.String()
}
func GetConfBool(jsonpath string)bool{
result := gjson.GetBytes(config_DATA_BYTE,jsonpath)
return result.Bool()
}
func GetConfint(jsonpath string)int64{
result := gjson.GetBytes(config_DATA_BYTE,jsonpath)
return result.Int()
}
func GetConfFloat(jsonpath string)float64{
result := gjson.GetBytes(config_DATA_BYTE,jsonpath)
return result.Float()
}