当前位置:网站首页>Go uses flag package to parse command line parameters
Go uses flag package to parse command line parameters
2022-07-26 23:23:00 【Jimmy_ jimi】
The goal is : Parsing command line arguments
analysis :
os.Args yes string The section of , All command line parameters can be stored , But it's not convenient to use . You can use it flag package , Parsing commands with parameters .
Result output :
var (
pwd string
host string
port int
user string
)
flag.StringVar(&user,"u","","username ,default empty")
flag.StringVar(&pwd,"pwd","","password ,default empty")
flag.StringVar(&host,"u","localhost","username ,default localhost")
flag.IntVar(&port,"port",3306,"post default 3306")
// This method must be called
flag.Parse()
fmt.Printf("user=%v pwd=%v host=%v port=%v",user,pwd,host,port)
边栏推荐
- Kt6368a Bluetooth chip development precautions and problem collection - long term update
- 数据供应链的转型 协调一致走向成功的三大有效策略
- Interview questions of Bank of Hangzhou [Hangzhou multi tester] [Hangzhou multi tester _ Wang Sir]
- Xinding acquires Ziguang holdings! Wanye enterprise: comprehensive transformation of integrated circuits!
- Three person management of system design
- Silicon Valley class lesson 7 - Tencent cloud on demand management module (2)
- Do you know the common core types of magnetic ring inductors?
- Promote the replacement of X86 with arm server chips, and Huawei and Feiteng carry the banner of localization!
- Restful interface specification
- Reinforcement learning weekly 55: lb-sgd, msp-drl & robust reinforcement learning against
猜你喜欢

Regular expressions and bypass case recurrence

实战项目:Boost搜索引擎

Science | University of Washington uses AI and structural prediction to design new proteins

Programmer growth chapter 29: how to motivate employees?

Dao:op token and non transferable NFT are committed to building a new digital democracy
What if redis memory is full? This is the right way to deal with it

The most classic Nature paper on Alzheimer's disease is suspected of fraud

SQL 基础知识

Vit:vision transformer super detailed with code

Pyqt5 how to set pushbutton click event to obtain file address
随机推荐
An online accident, I suddenly realized the essence of asynchrony
After closing the Suzhou plant, Omron Dongguan plant announced its dissolution, and more than 2000 people are facing unemployment!
Too busy with scientific research to take care of your family? Chen Ting: life cannot have only one fulcrum
The nature and proof of the center of gravity of [mathematics] tree
Disk expansion process and problems encountered in the virtual machine created by VMWare
sql多表查询的练习
The secret weapon of apple iphone11 series: U1 chip may usher in the era of ultra wideband
Vector execution engine framework gluten announced the official open source and appeared at spark technology summit
Boss; Can flick CDC Oracle finish reading the full amount of data, just like directly fetching data from the database
2019 biometric forum successfully ended: these ten highlights should not be missed!
TypeScript阶段学习
Pre research of data quality management tools Griffin vs deequ vs great expectations vs quality
ZTE: more than 50000 5g base stations have been shipped worldwide!
面试官问:JS的this指向
Novice online interview [Hangzhou multi tester] [Hangzhou multi tester _ Wang Sir]
New employees of black maredge takeout
Day07 MySQL knowledge points re summary and multi table query
2022年物联网行业有哪些用例?
Database full stack Engineers (devdbops) have low down payment and high return, and pay after employment
[MySQL] CentOS 7.9 installation and use mysql-5.7.39 binary version