Go Getopt —— Go 解析命令行参数工具
Go GetOpt,让你在 go 里解析命令行参数无聊地跟写 shell 脚本一样。 为了不引起混淆,以下说明将使用 go getopt 表示本代码仓库 shell getopt、getopt 命令 表示 util-linux 中的 getopt 二进制程序 getopt(或 C getopt)表示 libc 中的 getopt 方法 但在某个上下文(如标题说明了该段是 shell getopt)中可能有时会直接使用 getopt 指代。请各位注意区分。 怎么用 go get gitee.com/go-getopt/go-getopt package main import ( "fmt" "os" // 这里为了方便,直接使用 . 进行 import。 // 这样可以直接调用 GetOpt、Get 和 Shift 方法。 . "gitee.com/go-getopt/go-getopt" ) func main() { // 传入 os.Args、options 和 longOptions 字符串参数即可 err := GetOpt(os.A...
