本文整理汇总了Golang中flag.String函数的典型用法代码示例。如果您正苦于以下问题:Golang String函数的具体用法?Golang String怎么用?Golang String使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了String函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: main
func main() {
laddr := flag.String("listen", ":8001", "listen address")
baddr := flag.String("backend", "127.0.0.1:1234", "backend address")
secret := flag.String("secret", "the answer to life, the universe and everything", "tunnel secret")
tunnels := flag.Uint("tunnels", 1, "low level tunnel count, 0 if work as server")
flag.Int64Var(&tunnel.Timeout, "timeout", 10, "tunnel read/write timeout")
flag.UintVar(&tunnel.LogLevel, "log", 1, "log level")
flag.Usage = usage
flag.Parse()
app := &tunnel.App{
Listen: *laddr,
Backend: *baddr,
Secret: *secret,
Tunnels: *tunnels,
}
err := app.Start()
if err != nil {
fmt.Fprintf(os.Stderr, "start failed:%s\n", err.Error())
return
}
go handleSignal(app)
app.Wait()
}
开发者ID:xiaobodu,项目名称:gotunnel,代码行数:26,代码来源:main.go
示例2: main
func main() {
help := flag.Bool("help", false, "Show usage")
username := flag.String("u", "", "Specify Github user")
password := flag.String("p", "", "Specify Github password")
flag.Usage = func() {
fmt.Printf("Usage:\n")
flag.PrintDefaults()
}
flag.Parse()
if *help == true || *username == "" || *password == "" {
flag.Usage()
return
}
ghc, err := ghclient.NewGithubClient(*username, *password, ghclient.AUTH_USER_PASSWORD)
gistsc := ghgists.NewGists(ghc)
res, err := gistsc.GetPublicGistsList()
jr, err := res.Json()
fmt.Printf("JSON: %v\nERROR: %v\n", jr, err)
print("\n\nLOADING NEXT PAGE...\n\n")
res, err = res.GetNextPage()
jr, err = res.Json()
fmt.Printf("JSON: %v\nERROR: %v\n", jr, err)
}
开发者ID:alcacoop,项目名称:go-github-client,代码行数:33,代码来源:main.go
示例3: main
func main() {
certpath := flag.String("cert", "", "The path to a PEM certificate")
keypath := flag.String("key", "", "The path to a PEM key")
flag.Parse()
if len(*certpath) == 0 || len(*keypath) == 0 {
flag.PrintDefaults()
return
}
ctx := gossl.NewContext(gossl.SSLv3Method())
ctx.SetOptions(gossl.OpNoCompression)
err := ctx.UsePrivateKeyFile(*keypath, gossl.FileTypePem)
if err != nil {
panic(err)
}
ctx.UseCertificateFile(*certpath, gossl.FileTypePem)
if err != nil {
panic(err)
}
l, err := net.Listen("tcp", ":8000")
if err != nil {
panic(err)
}
l, err = gossl.NewListener(l, ctx)
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hello, %q\n", html.EscapeString(r.URL.Path))
})
http.Serve(l, nil)
}
开发者ID:runcom,项目名称:gossl,代码行数:29,代码来源:httpserver.go
示例4: init
func init() {
condition = flag.String("condition", "<ID>", "Condition ID, set only to check a single alert (optional)")
stream = flag.String("stream", "<ID>", "Stream ID (mandatory)")
api_url = flag.String("url", "http://localhost:12900", "URL to Graylog2 api (optional)")
user = flag.String("user", "<username>", "API username (mandatory)")
pass = flag.String("password", "<password>", "API password (mandatory)")
}
开发者ID:aanriot,项目名称:check-graylog2-stream,代码行数:7,代码来源:check-graylog2-stream.go
示例5: main
func main() {
introText := "SIMPLE TWITTER REFORMATTER \n (╯°□°)╯︵ ┻━┻) \n"
fmt.Printf(introText)
key := flag.String("key", "nokey", "Twitter consumer key")
secret := flag.String("sec", "nosecret", "Twitter consumer secret")
debug := flag.Bool("debug", false, "Debug logging level")
numTweets := flag.Int("num", 3, "Number of tweets to retrieve")
flag.Parse()
access_token, err := getBearerToken(*key, *secret, *debug)
if err != nil || access_token == "" {
log.Fatal("Could not retrieve token to make twitter API request")
os.Exit(1)
}
// Create a very basic channel with tweets getting passed into the expander
// Wait for it to finish executing before quiting.
var tweetChannel chan string = make(chan string)
var wg sync.WaitGroup
wg.Add(1)
go tweetRetriever(access_token, *numTweets, tweetChannel, &wg, *debug)
go textExpander(tweetChannel)
wg.Wait()
}
开发者ID:zachgoldstein,项目名称:go-test-app,代码行数:26,代码来源:plan.go
最后编辑: kuteng 文档更新时间: 2021-08-23 19:14 作者:kuteng