7 Star 44 Fork 4

小蚂蚁 / clop

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
default.go 453 Bytes
一键复制 编辑 原始数据 按行查看 历史
guonaihong 提交于 2020-03-13 12:33 . bugfix,正好测试下ci/cd
package clop
import (
"encoding/json"
"reflect"
)
func isDefvalJSON(def []byte) bool {
if def[0] == '[' && len(def) > 2 && def[len(def)-1] == ']' ||
def[0] == '{' && len(def) > 2 && def[len(def)-1] == '}' {
return json.Valid(def)
}
return false
}
func setDefaultValue(def string, v reflect.Value) error {
def2 := StringToBytes(def)
if isDefvalJSON(def2) {
return json.Unmarshal(def2, v.Addr().Interface())
}
return setBase(def, v)
}
Go
1
https://gitee.com/guonaihong/clop.git
git@gitee.com:guonaihong/clop.git
guonaihong
clop
clop
master

搜索帮助