diff --git a/encoding/gini/gini.go b/encoding/gini/gini.go index a756a7413..deb9c523f 100644 --- a/encoding/gini/gini.go +++ b/encoding/gini/gini.go @@ -16,7 +16,7 @@ import ( "strings" ) -// Decode converts INI format to map. +//Decode converts INI format to map func Decode(data []byte) (res map[string]interface{}, err error) { res = make(map[string]interface{}) fieldMap := make(map[string]interface{}) @@ -72,10 +72,13 @@ func Decode(data []byte) (res map[string]interface{}, err error) { } + if haveSection == false { + return nil, fmt.Errorf("Failed to parse INI file, not found section") + } return res, nil } -// Encode converts map to INI format. +//Encode converts map to INI format func Encode(data map[string]interface{}) (res []byte, err error) { w := new(bytes.Buffer) @@ -102,11 +105,12 @@ func Encode(data map[string]interface{}) (res []byte, err error) { return res, nil } -// ToJson convert INI format to JSON. +//ToJson convert INI format to JSON func ToJson(data []byte) (res []byte, err error) { iniMap, err := Decode(data) if err != nil { return nil, err } + return json.Marshal(iniMap) }