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) }
有疑问加站长微信联系(非本文作者)