当前位置:网站首页>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)
边栏推荐
- 数据库全栈工程师(DevDBOps)低首付、高回报,先就业后付款
- About statefulwidget, you have to know the principle and main points!
- Silicon Valley class lesson 5 - Tencent cloud object storage and course classification management
- 杰理下载器强制下载工具的使用介绍_AC695N696NAD14AD15全系列支持
- Easily implement seckill system with redis! (including code)
- The most classic Nature paper on Alzheimer's disease is suspected of fraud
- Siliwei's counterattack: huiding's under screen optical fingerprint patent involved in the case was declared invalid
- Kingbasees SQL language reference manual of Jincang database (3.1.1.14. scope type)
- 电脑开机后内存占用过高(50%以上)
- Ribbon负载均衡
猜你喜欢

Programmer growth chapter 29: how to motivate employees?

数据供应链的转型 协调一致走向成功的三大有效策略

Easily implement seckill system with redis! (including code)

The interviewer asked: this point of JS

About statefulwidget, you have to know the principle and main points!

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

MySQL random paging to get non duplicate data

Page file system based on C language

Import of MySQL data

Vit:vision transformer super detailed with code
随机推荐
How to recover the original data when the U disk is damaged, and how to recover the damaged data when the U disk is damaged
Cheaper than seals, with a large space for shape explosion. Is there really no match for 200000 or so? Chang'an's new "King fried" is cost-effective
Basic use of gateway
Restful interface specification
关于 StatefulWidget,你不得不知道的原理和要点!
Day07 MySQL knowledge points re summary and multi table query
数据供应链的转型 协调一致走向成功的三大有效策略
Learn various details and thoughts of chatroom implementation in Muduo
程序员成长第二十九篇:如何激励员工?
SQL 基础知识
Apifox -- a better API testing tool than postman
2019 biometric forum successfully ended: these ten highlights should not be missed!
The most classic Nature paper on Alzheimer's disease is suspected of fraud
HCIA-R&S自用笔记(18)园区网架构基础、交换机工作原理、VLAN原理
为什么我还在CSDN写文章?一段陪伴学习的历程。
Lesson 2 of Silicon Valley classroom - building project environment and developing lecturer management interface
黑马瑞吉外卖之新增员工
[Luogu] p2341 popular cattle
An online accident, I suddenly realized the essence of asynchrony
My SQL is OK. Why is it still so slow? MySQL locking rules