Go 的配置文件解析扩展包 GoConfig

码农软件 · 软件分类 · 语法解析工具 · 2019-12-12 09:59:42

软件介绍

golang的一个扩展包,用以方便的解析配置文件,目前很好的支持:xml,json,yaml,toml;也简单的支持:ini,但不推荐使用。

一个简单例子:

{
  "Port": 8080,
  "Instance": [
    {
      "Name": "gitbook",
      "Path": "/gitbook",
      "Cmd": ["ls", "ll"],
      "User": "dingdayu"
    }
  ]
}
	// 实例
	type Instance struct {
		Name 	string
		Path	string
		Cmd		[]string
		User	string
	}

	// 配置
	type Config struct {
		Port int
		Instance []Instance
	}

	var conf Config
	err := config.New("conf.json", &conf)
	if err != nil {
		fmt.Println(err.Error())
	}
	fmt.Println(conf)

安装:

go get github.com/dingdayu/golangtools/config

GitHub地址:https://github.com/dingdayu/golangtools/

本文地址:https://codercto.com/soft/d/20972.html

Pattern Recognition and Machine Learning

Pattern Recognition and Machine Learning

Christopher Bishop / Springer / 2007-10-1 / USD 94.95

The dramatic growth in practical applications for machine learning over the last ten years has been accompanied by many important developments in the underlying algorithms and techniques. For example,......一起来看看 《Pattern Recognition and Machine Learning》 这本书的介绍吧!

MD5 加密
MD5 加密

MD5 加密工具

SHA 加密
SHA 加密

SHA 加密工具

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试