package main import ( "flag" "fmt" ) var name string func init(){ flag.StringVar(&name,"name","everyone","The greting object") } func main(){ flag.Parse() fmt.Printf("hello,%s!\n",name) }
go run demo2.go -name="huaihe" Hello, huaihe!