GoLang 捕获命令行参数

前端之家收集整理的这篇文章主要介绍了GoLang 捕获命令行参数前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
                                                                                                     
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","this is s1")   i_int := flag.Int("i","this is i") //返回 int 指针  flag.IntVar(&i1_int,"i1","this is i1")   i64_int := flag.Int64("i64","this is i64") // 返回 int64 指针  flag.Int64Var(&i64_1_int,"i64","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/
原文链接:https://www.f2er.com/go/189258.html

猜你在找的Go相关文章