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://www.codercto.com/soft/d/20972.html

分布式算法导论

分布式算法导论

特尔 (Gerard Tel) / 电子工业出版社 / 2003-7 / 59.00

《分布式算法导论(第2版)(英文版)》由电子工业出版社出版。一起来看看 《分布式算法导论》 这本书的介绍吧!

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

RGB HSV 转换
RGB HSV 转换

RGB HSV 互转工具