本文整理汇总了Golang中flag.Usage函数的典型用法代码示例。如果您正苦于以下问题:Golang Usage函数的具体用法?Golang Usage怎么用?Golang Usage使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Usage函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: main
func main() {
flag.Usage = Usage
flag.Parse()
if *showVersion {
fmt.Println("goobar", Version)
os.Exit(0)
}
if *listenAddress == "" {
fmt.Fprintln(os.Stderr, "you must supply an address to listen on")
flag.Usage()
os.Exit(1)
}
if *memcacheBackend == "" {
fmt.Fprintln(os.Stderr, "you must specify a memcached backend")
flag.Usage()
os.Exit(1)
}
log.SetPrefix("goobar ")
log.SetFlags(log.Ldate | log.Lmicroseconds)
tsock, err := net.Listen("tcp", *listenAddress)
if err != nil {
panic(err)
}
server.Main(tsock)
}
开发者ID:sofuture,项目名称:goobar,代码行数:31,代码来源:goobar.go
示例2: main
func main() {
flag.Usage = usage
flag.Parse()
cachingHTTPClient = util.CachingHttpClient()
if *tokenFlag == "" || cachingHTTPClient == nil {
flag.Usage()
return
}
ds = clientFlags.CreateDataset()
if ds == nil {
flag.Usage()
return
}
defer ds.Store().Close()
if err := clientFlags.CreateProgressFile(); err != nil {
fmt.Println(err)
} else {
defer clientFlags.CloseProgressFile()
}
token := oauth2.Token{AccessToken: *tokenFlag}
authHTTPClient = oauth2.NewClient(oauth2.NoContext, oauth2.StaticTokenSource(&token))
start = time.Now()
var user = getUser()
printStats(user)
userRef := ds.Store().WriteValue(user)
fmt.Printf("userRef: %s\n", userRef.TargetRef())
_, err := ds.Commit(userRef)
d.Exp.NoError(err)
}
开发者ID:arv,项目名称:noms-old,代码行数:35,代码来源:facebook.go
示例3: main
func main() {
flag.Usage = func() {
fmt.Fprintf(os.Stderr, "Usage: %s size\n", os.Args[0])
fmt.Fprintf(os.Stderr, " Must specify an odd integer for size\n")
flag.PrintDefaults()
}
flag.Parse()
if flag.NArg() != 1 {
flag.Usage()
return
}
size, err := strconv.Atoi(flag.Arg(0))
if err != nil {
flag.Usage()
return
}
square, err := magicsquare.MagicSquare(size)
if err != nil {
flag.Usage()
return
}
for _, row := range square {
for _, col := range row {
fmt.Printf("%5v", col)
}
fmt.Printf("\n")
}
}
开发者ID:jmcvetta,项目名称:magicsquare,代码行数:29,代码来源:main.go
示例4: cmdCreateTeam
func cmdCreateTeam() {
if flagCmdCreateTeam {
if len(flagTeamName) == 0 {
fmt.Fprintln(os.Stderr, "flag needs an argument: -team_name")
flag.Usage()
os.Exit(1)
}
if len(flagEmail) == 0 {
fmt.Fprintln(os.Stderr, "flag needs an argument: -email")
flag.Usage()
os.Exit(1)
}
c := &api.Context{}
c.RequestId = model.NewId()
c.IpAddress = "cmd_line"
team := &model.Team{}
team.DisplayName = flagTeamName
team.Name = flagTeamName
team.Email = flagEmail
team.Type = model.TEAM_INVITE
api.CreateTeam(c, team)
if c.Err != nil {
if c.Err.Message != "A team with that domain already exists" {
l4g.Error("%v", c.Err)
flushLogAndExit(1)
}
}
os.Exit(0)
}
}
开发者ID:cbayleOL,项目名称:platform,代码行数:35,代码来源:mattermost.go
示例5: main
// Remember Exit(0) is success, Exit(1) is failure
func main() {
flag.Var(&slaveList, "control", "list of ip:port addresses to control")
flag.Parse()
if len(*testUrl) == 0 {
flag.Usage()
os.Exit(1)
}
if len(slaveList) > 0 && *listen != 0 {
fmt.Fprintf(os.Stderr, "You can't have both --listen and --control flags")
flag.Usage()
os.Exit(1)
}
rand.Seed(time.Now().Unix())
// set up logging
logWriter, err := os.OpenFile(*logFile, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666)
if err != nil {
println(err)
os.Exit(1)
}
log.SetOutput(logWriter)
TRACE = log.New(ioutil.Discard,
"TRACE: ",
log.Ldate|log.Ltime|log.Lshortfile)
INFO = log.New(logWriter,
"INFO: ",
log.Ldate|log.Ltime|log.Lshortfile)
ERROR = log.New(logWriter,
"ERROR: ",
log.Ldate|log.Ltime|log.Lshortfile)
INFO.Println("beginning run")
os.Exit(realMain())
}
开发者ID:kgoess,项目名称:webserver-loadtest,代码行数:36,代码来源:webserver-loadtest.go
最后编辑: kuteng 文档更新时间: 2021-08-23 19:14 作者:kuteng