Skip to content

Instantly share code, notes, and snippets.

@artyom
Created May 16, 2014 05:39
Show Gist options
  • Select an option

  • Save artyom/d67e54449092b85bb95b to your computer and use it in GitHub Desktop.

Select an option

Save artyom/d67e54449092b85bb95b to your computer and use it in GitHub Desktop.
Go flag supports both 'long' and 'short' options
package main
import (
"flag"
"fmt"
)
func main() {
n := 42
flag.IntVar(&n, "num", n, "your number ('long' option)")
flag.IntVar(&n, "n", n, "your number ('short' option)")
flag.Parse()
fmt.Println("your number is:", n)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment