menu Chancel's blog
rss_feed
Chancel's blog
秋雨一何碧,山色倚晴空。

Go解析命令行参数

作者:Chancel Yang, 时间:2022 Jun 06, 阅读:71

flag包,用于解析命令行参数,代码示例如下

package main

import (
    "flag"
    "fmt"
)

func main(){
    var name = flag.String("name","chancel","input your name")
    var age = flag.Int("age",10,"input your age")
    flag.Parse()
    fmt.Println("Hello ",*name," age:",*age)
}
// 输出
➜ go run main.go --name demo --age 18
Hello  demo  age: 18

[[replyMessage== null?"发表评论":"发表评论 @ " + replyMessage.m_author]]

account_circle
email
web_asset
textsms

评论列表([[messageResponse.total]])

还没有可以显示的留言...
[[messageItem.m_author]] [[messageItem.m_author]]
[[messageItem.create_time]]
[[getEnviron(messageItem.m_environ)]]
[[subMessage.m_author]] [[subMessage.m_author]] @ [[subMessage.parent_message.m_author]] [[subMessage.parent_message.m_author]]
[[subMessage.create_time]]
[[getEnviron(messageItem.m_environ)]]