Go中基于结构的参数解析-Golang开发

时间:2021-05-26 15:09:39
【文件属性】:
文件名称:Go中基于结构的参数解析-Golang开发
文件大小:41KB
文件格式:ZIP
更新时间:2021-05-26 15:09:39
Golang Command Line go-arg Go的基于结构的参数解析,通过定义结构来声明程序的命令行参数。 var args struct {Foo string Bar bool} arg.MustParse(&args)fmt.Println(args.Fo go-arg Go的基于结构的参数解析,通过定义结构来声明程序的命令行参数。 Bar bool} arg.MustParse(&args)fmt.Println(args.Foo,args.Bar)$ ./example --foo = hello --bar hello true安装go get github.com/alexflint/go-arg必需的参数var args struct {ID int`arg:“ required”`Timeout time.Duration} arg.MustParse(&args)$ ./example用法:示例--id ID [--timeout TIMEOUT]错误:
【文件预览】:
go-arg-master
----parse_test.go(31KB)
----reflect.go(3KB)
----reflect_test.go(3KB)
----.gitignore(266B)
----sequence.go(3KB)
----usage_test.go(12KB)
----README.md(12KB)
----.github()
--------workflows()
--------banner.jpg(10KB)
----doc.go(1KB)
----sequence_test.go(4KB)
----LICENSE(1KB)
----go.mod(132B)
----subcommand.go(1KB)
----go.sum(700B)
----example_test.go(10KB)
----usage.go(6KB)
----subcommand_test.go(9KB)
----parse.go(19KB)

网友评论