コード例 #1
0
ファイル: jsonConfig.go プロジェクト: catgatp/gol
// Load load & remove comments from source .json file
func Load(fromPath string, toVar interface{}) {
	file, e := ioutil.ReadFile(fromPath)
	err.Panic(e)
	file = RemoveComment(file)
	err.Panic(json.Unmarshal(file, toVar))
}
コード例 #2
0
ファイル: jsonConfig.go プロジェクト: catgatp/gol
func LoadBuf(file []byte, toVar interface{}) {

	file = RemoveComment(file)
	err.Panic(json.Unmarshal(file, toVar))
}
コード例 #3
0
ファイル: jsonConfig.go プロジェクト: catgatp/gol
// Save config to json format file
func Save(fromVar interface{}, toPath string) {
	data, e := json.Marshal(fromVar)
	err.Panic(e)
	e = ioutil.WriteFile(toPath, data, 0664)
	err.Panic(e)
}