本文整理汇总了Golang中flag.Uint函数的典型用法代码示例。如果您正苦于以下问题:Golang Uint函数的具体用法?Golang Uint怎么用?Golang Uint使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Uint函数的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: decodeRefArg
func decodeRefArg(name, typeName string) (interface{}, error) {
switch strings.ToLower(typeName) {
case "*bool":
newValue := flag.Bool(name, app.DefaultBoolValue, name)
return newValue, nil
case "bool":
newValue := flag.Bool(name, app.DefaultBoolValue, name)
return *newValue, nil
case "*string":
newValue := flag.String(name, app.DefaultStringValue, name)
return *newValue, nil
case "string":
newValue := flag.String(name, app.DefaultStringValue, name)
return *newValue, nil
case "*time.duration":
newValue := flag.Duration(name, app.DefaultDurationValue, name)
return *newValue, nil
case "time.duration":
newValue := flag.Duration(name, app.DefaultDurationValue, name)
return *newValue, nil
case "*float64":
newValue := flag.Float64(name, app.DefaultFloat64Value, name)
return *newValue, nil
case "float64":
newValue := flag.Float64(name, app.DefaultFloat64Value, name)
return *newValue, nil
case "*int":
newValue := flag.Int(name, app.DefaultIntValue, name)
return *newValue, nil
case "int":
newValue := flag.Int(name, app.DefaultIntValue, name)
return *newValue, nil
case "*int64":
newValue := flag.Int64(name, app.DefaultInt64Value, name)
return *newValue, nil
case "int64":
newValue := flag.Int64(name, app.DefaultInt64Value, name)
return *newValue, nil
case "*uint":
newValue := flag.Uint(name, app.DefaultUIntValue, name)
return *newValue, nil
case "uint":
newValue := flag.Uint(name, app.DefaultUIntValue, name)
return *newValue, nil
case "*uint64":
newValue := flag.Uint64(name, app.DefaultUInt64Value, name)
return *newValue, nil
case "uint64":
newValue := flag.Uint64(name, app.DefaultUInt64Value, name)
return *newValue, nil
}
return nil, fmt.Errorf("unknow type %s for argument %s", typeName, name)
}
开发者ID:goatcms,项目名称:goat-core,代码行数:60,代码来源:injector.go
示例3: handleFlags
func handleFlags() (*CliOptions, bool) {
flag.Usage = Usage
_ = flag.String("serveraddr", "127.0.0.1", "Server address to listen") // ignored
serverPort := flag.Uint("port", 9000, "Port to listen")
portLayerAddr := flag.String("port-layer-addr", "127.0.0.1", "Port layer server address")
portLayerPort := flag.Uint("port-layer-port", 9001, "Port Layer server port")
debug := flag.Bool("debug", false, "Enable debuglevel logging")
flag.Parse()
// load the vch config
src, err := extraconfig.GuestInfoSource()
if err != nil {
log.Fatalf("Unable to load configuration from guestinfo: %s", err)
}
extraconfig.Decode(src, &vchConfig)
if *debug || vchConfig.Diagnostics.DebugLevel > 0 {
log.SetLevel(log.DebugLevel)
}
cli := &CliOptions{
serverPort: *serverPort,
portLayerAddr: fmt.Sprintf("%s:%d", *portLayerAddr, *portLayerPort),
proto: "tcp",
}
return cli, true
}
开发者ID:vmware,项目名称:vic,代码行数:31,代码来源:main.go
示例4: handleFlags
func handleFlags() (*CliOptions, bool) {
flag.Usage = Usage
enableTLS := flag.Bool("TLS", false, "Use TLS; implied by --tlsverify")
verifyTLS := flag.Bool("tlsverify", false, "Use TLS and verify the remote")
cafile := flag.String("tls-ca-certificate", "", "Trust certs signed only by this CA")
certfile := flag.String("tls-certificate", "", "Path to TLS certificate file")
keyfile := flag.String("tls-key", "", "Path to TLS Key file")
serverAddr := flag.String("serveraddr", "127.0.0.1", "Server address to listen")
serverPort := flag.Uint("port", 9000, "Port to listen")
portLayerAddr := flag.String("port-layer-addr", "127.0.0.1", "Port layer server address")
portLayerPort := flag.Uint("port-layer-port", 9001, "Port Layer server port")
debug := flag.Bool("debug", false, "Enable debuglevel logging")
flag.Parse()
if *enableTLS && (len(*certfile) == 0 || len(*keyfile) == 0) {
fmt.Fprintf(os.Stderr, "TLS requested, but tls-certificate and tls-key were all not specified\n")
return nil, false
}
if *verifyTLS {
*enableTLS = true
if len(*certfile) == 0 || len(*keyfile) == 0 || len(*cafile) == 0 {
fmt.Fprintf(os.Stderr, "tlsverfiy requested, but tls-ca-certificate, tls-certificate, tls-key were all not specified\n")
return nil, false
}
}
cli := &CliOptions{
enableTLS: *enableTLS,
verifyTLS: *verifyTLS,
cafile: *cafile,
certfile: *certfile,
keyfile: *keyfile,
serverAddr: *serverAddr,
serverPort: *serverPort,
fullserver: fmt.Sprintf("%s:%d", *serverAddr, *serverPort),
portLayerAddr: fmt.Sprintf("%s:%d", *portLayerAddr, *portLayerPort),
proto: "tcp",
}
// load the vch config
src, err := extraconfig.GuestInfoSource()
if err != nil {
log.Errorf("Unable to load configuration from guestinfo")
}
extraconfig.Decode(src, &vchConfig)
if *debug || vchConfig.Diagnostics.DebugLevel > 0 {
log.SetLevel(log.DebugLevel)
}
return cli, true
}
开发者ID:kjplatz,项目名称:vic,代码行数:57,代码来源:main.go
示例5: main
func main() {
// Define and parse flags.
id := flag.Uint("id", 0, "Set the client node ID to connect to.")
rate = flag.Uint("rate", 0, "Sets the maximum messages per second.")
flag.Parse()
// Validate flags.
if *id == 0 || *id > 0xFFFF {
log.Fatal("Invalid node ID specified.")
}
// Load configuration from config file.
loadConfig()
fmt.Printf("Loaded configuration, ID to connect to is %d.\n", *id)
conn, err := connect.TestDial(uint16(*id))
if err != nil {
log.Fatal(err)
}
var msg cliproto_up.Authenticate
msg.Username = new(string)
msg.Password = new(string)
msg.SessionId = new(uint64)
*msg.Username = "msgsource"
*msg.Password = "msgsource"
conn.SendProto(2, &msg)
for {
respMsg, ok := <-conn.Received
if !ok {
log.Fatal("connection error")
}
switch *respMsg.MsgType {
case 2:
conn.Close()
log.Fatal("auth failed")
case 3:
log.Print("authenticated, follow msgsink...")
var followMsg cliproto_up.FollowUsername
followMsg.Username = new(string)
*followMsg.Username = "msgsink"
conn.SendProto(3, &followMsg)
case 4:
log.Fatal("follow failed")
case 6:
handleData(respMsg.Content)
case 7:
log.Print("following msgsink, sending msgs...")
go sendMessages(conn)
}
}
}
开发者ID:jbeshir,项目名称:unanimity,代码行数:56,代码来源:main.go
最后编辑: kuteng 文档更新时间: 2021-08-23 19:14 作者:kuteng