Skip to content

Instantly share code, notes, and snippets.

@bernerdschaefer
Created August 23, 2016 21:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bernerdschaefer/c29c55d52b55299afbe22a214e34e282 to your computer and use it in GitHub Desktop.
Save bernerdschaefer/c29c55d52b55299afbe22a214e34e282 to your computer and use it in GitHub Desktop.
package main
type Options struct {
Input string
Output string
Switch bool
}
func parseFlags(options *Options) {
flag.StringVar(&options.Input, "", "input file")
flag.StringVar(&options.Output, "", "output file")
flag.BoolVar(&options.Switch, true, "switch")
// ...
flag.Parse()
}
func main() {
var options = &Options{}
parseFlags(options)
if err := options.Valid(); err != nil {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment