Create a gist now

Instantly share code, notes, and snippets.

@matope /main.go
Last active Aug 29, 2015

What would you like to do?
double-dash hyphen
package main
import (
var hoge *string
var str string
func init() {
hoge = flag.String("hoge", "default-value", "First string option")
flag.StringVar(&str, "str", "default-value", "Second string option")
func main() {
fmt.Println("hoge:", *hoge)
fmt.Println("str:", str)
func myParse() {
fs := flag.NewFlagSet(os.Args[0], flag.ExitOnError)
fs.Usage = flag.Usage
flag.CommandLine.VisitAll(func(f *flag.Flag) {
fs.Var(f.Value, f.Name, f.Usage)
fs.Var(f.Value, "-"+f.Name, f.Usage)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment