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

GOOGLE HACKS

GOOGLE HACKS

Rael Dornfest、Tara Calishain / 卞军、谢伟华、朱炜 / 电子工业 / 2006-1 / 49.00元

GOOGLE HACKS巧妙使用网络搜索的技巧和工具(第二版)一起来看看 《GOOGLE HACKS》 这本书的介绍吧!

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

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

正则表达式在线测试

HSV CMYK 转换工具
HSV CMYK 转换工具

HSV CMYK互换工具