feat: auto generate drivers language json

This commit is contained in:
Noah Hsu
2022-08-26 15:08:31 +08:00
parent d9ee174dd3
commit 7425e001db
7 changed files with 117 additions and 27 deletions

View File

@ -10,13 +10,13 @@ import (
var Json = json.ConfigCompatibleWithStandardLibrary
// WriteJsonToFile write struct to json file
func WriteJsonToFile(src string, conf interface{}) bool {
data, err := Json.MarshalIndent(conf, "", " ")
func WriteJsonToFile(dst string, data interface{}) bool {
str, err := Json.MarshalIndent(data, "", " ")
if err != nil {
log.Errorf("failed convert Conf to []byte:%s", err.Error())
return false
}
err = ioutil.WriteFile(src, data, 0777)
err = ioutil.WriteFile(dst, str, 0777)
if err != nil {
log.Errorf("failed to write json file:%s", err.Error())
return false