package main
import (
"flag"
"fmt"
)
func main() {
methodPtr := flag.String("method", "default", "method of sample")
valuePtr := flag.Int("value", -1, "value of sample")
flag.Parse()
fmt.Println(*methodPtr, *valuePtr)
}
// 输出
MacintoshdeMacBook-Pro-139:terminal elasticnotes$ go run flag.go
default -1
MacintoshdeMacBook-Pro-139:terminal elasticnotes$ go run flag.go -method 你好
你好 -1