package main import ( "flag" "fmt" ) func main() { var ( s1_string string i1_int int i64_1_int int64 ) s_string := flag.String("s", "0", "this is s") //返回 string 指针 flag.StringVar(&s1_string, "s1", "0", "this is s1") i_int := flag.Int("i", 0, "this is i") //返回 int 指针 flag.IntVar(&i1_int, "i1", 0, "this is i1") i64_int := flag.Int64("i64", 0, "this is i64") // 返回 int64 指针 flag.Int64Var(&i64_1_int, "i64", 0, "this is i64_1_int") flag.Parse() //解析注册的flag fmt.Println(*s_string) fmt.Println(s1_string) fmt.Println(*i_int) //int fmt.Println(i1_int) fmt.Println(*i64_int) fmt.Println(i64_1_int) }
本文来自:CSDN博客
感谢作者:liangguangchuan
查看原文:GoLang 捕获命令行参数
查看原文:http://www.zoues.com/2016/10/27/golang-%e6%8d%95%e8%8e%b7%e5%91%bd%e4%bb%a4%e8%a1%8c%e5%8f%82%e6%95%b0/
GoLang 捕获命令行参数
最新推荐文章于 2024-02-21 17:15:29 发布