golang中关于flag模块的概述(知识点整理)
发布时间
阅读量:
阅读量
1. flag常用函数
无论采用C语言、Golang语言还是其他编程语言,在启动应用程序时均可附加若干参数,系统将依据接收到的参数执行相应的操作。例如:./main -mode online -model bert_ch。在Go语言中,可以通过便捷的flag模块实现对命令行参数的解析功能。
// 解析字符串
type string string
func String(name string, value string, usage string) *string
// 解析整数变量
type int int
func Int(name string, value int, usage string) *int
// 解析bool变量
type bool bool
func Bool(name string, value bool, usage string) *bool
type float64 float64
func Float64(name string, value float64, usage string) *float64
type int64
全部评论 (0)
还没有任何评论哟~
