Goのflagパッケージで最高のusageを出力する方法
This content is a draft and will not be included in production builds.
デフォルト値
Section titled “デフォルト値”ゼロ値でなければデフォルト値を出力できる。
flag.Var(&overwriteFields, "replace", "field-value expression")flag.Usage = func() { w := flag.CommandLine.Output() fmt.Fprintln(w, "usage:", progname, "[options] [file ...]") fmt.Fprintln(w, "\noptions:") flag.PrintDefaults()}flag.Parse()