备忘
package main
import (“fmt”
“flag”
)
//参数名, 参数默认值,参数说明
var (loopnum =flag.Int(“l”,10,”loop num.”)
loopurl =flag.String(“u”,”www.simonzhang.net”,”get url.”)
)
func main() {
flag.Parse()
fmt.Println(“loop num:”, loopnum)
fmt.Println(“url:”, *loopurl)
}
编译后使用
flag -l=11 -u=http://www.simonzhang.net
发表评论