• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang flag.StringVar函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中flag.StringVar函数的典型用法代码示例。如果您正苦于以下问题:Golang StringVar函数的具体用法?Golang StringVar怎么用?Golang StringVar使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了StringVar函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: init

func init() {
	flag.StringVar(&Package, "p", "atomap", "package name")
	flag.StringVar(&Key, "k", "int", "key type")
	flag.StringVar(&Value, "v", "int", "value type")
	flag.StringVar(&File, "f", "atomap.go", "file name")
	flag.Parse()
}
开发者ID:Jxck,项目名称:AtoMap,代码行数:7,代码来源:generate.go


示例2: main

func main() {
	var bindAddress string
	var port int

	flag.IntVar(&port, "port", 9125, "Port to listen on")
	flag.IntVar(&port, "p", 9125, "Port to listen on")

	flag.StringVar(&bindAddress, "bind", "0.0.0.0", "IP Address to listen on")
	flag.StringVar(&bindAddress, "b", "0.0.0.0", "IP Address to listen on")

	flag.StringVar(&prefix, "prefix", "statsrelay", "The prefix to use with self generated stats")

	flag.BoolVar(&verbose, "verbose", false, "Verbose output")
	flag.BoolVar(&verbose, "v", false, "Verbose output")

	flag.Parse()

	if len(flag.Args()) == 0 {
		log.Fatalf("One or most host specifications are needed to locate statsd daemons.\n")
	}

	hashRing = consistent.New()
	hashRing.NumberOfReplicas = 1

	for _, v := range flag.Args() {
		var addr *net.UDPAddr
		var err error
		host := strings.Split(v, ":")

		switch len(host) {
		case 1:
			log.Printf("Invalid statsd location: %s\n", v)
			log.Fatalf("Must be of the form HOST:PORT or HOST:PORT:INSTANCE\n")
		case 2:
			addr, err = net.ResolveUDPAddr("udp", v)
			if err != nil {
				log.Printf("Error parsing HOST:PORT \"%s\"\n", v)
				log.Fatalf("%s\n", err.Error())
			}
		case 3:
			addr, err = net.ResolveUDPAddr("udp", host[0]+":"+host[1])
			if err != nil {
				log.Printf("Error parsing HOST:PORT:INSTANCE \"%s\"\n", v)
				log.Fatalf("%s\n", err.Error())
			}
		default:
			log.Fatalf("Unrecongnized host specification: %s\n", v)
		}

		if addr != nil {
			udpAddr[v] = addr
			hashRing.Add(v)
		}
	}

	epochTime = time.Now().Unix()
	runServer(bindAddress, port)

	log.Printf("Normal shutdown.\n")
}
开发者ID:denen99,项目名称:statsrelay,代码行数:60,代码来源:statsrelay.go


示例3: init

func init() {
	flag.IntVar(&N, "N", 100, "Matrix rows/cols.")

	// blocking size; 0 is unblocked versions
	flag.IntVar(&KB, "KB", 0, "Blocking size for blocked invocations")

	// parameters for basic matrix operations
	flag.IntVar(&MB, "MB", 68, "Row blocking size.")
	flag.IntVar(&NB, "NB", 68, "Column blocking size.")
	flag.IntVar(&VPsize, "H", 68, "Viewport size.")
	flag.IntVar(&nWorker, "W", 2, "Number of workers for parallel runs")

	flag.BoolVar(&singleTest, "s", false, "Run single test run for given matrix size.")
	flag.BoolVar(&refTest, "r", false, "Test with lapack reference function.")
	flag.StringVar(&sizeList, "L", "", "Comma separated list of matrix sizes.")
	flag.IntVar(&testCount, "n", 5, "Number of test runs.")

	flag.BoolVar(&noSPD, "-nP", false, "Matrix is not SPD.")
	flag.BoolVar(&testUpper, "U", false, "Matrix is UPPER triangular. ")
	flag.BoolVar(&check, "C", false, "Check result against lapack reference.")
	flag.BoolVar(&verbose, "v", false, "Be verbose.")
	flag.BoolVar(&asGflops, "g", false, "Report as Gflops.")
	flag.BoolVar(&asEps, "e", false, "Report as result elements per seconds.")
	flag.StringVar(&testName, "T", "test", "Test name for reporting")
	flag.StringVar(&fileName, "F", "saved.dat", "Filename for source data")
}
开发者ID:hrautila,项目名称:matops,代码行数:26,代码来源:perf_chol.go


示例4: main

func main() {
	var url, origin string
	flag.StringVar(&url, "url", "ws://127.0.0.1:9999/echo", "websocket URL")
	flag.StringVar(&origin, "origin", "http://localhost/", "origin header")
	flag.Parse()

	if url == "" {
		flag.Usage()
		os.Exit(1)
	}

	ws, err := websocket.Dial(url, "", origin)
	if err != nil {
		log.Fatal(err)
	}

	go func() {
		var msg = make([]byte, 512)
		for {
			n, err := ws.Read(msg)
			if err != nil {
				log.Fatal(err)
			}
			fmt.Printf("R: %s\nS: ", msg[:n])
		}
	}()

	fmt.Print("S: ")
	sc := bufio.NewScanner(os.Stdin)
	for sc.Scan() {
		if _, err := ws.Write(sc.Bytes()); err != nil {
			log.Fatal(err)
		}
	}
}
开发者ID:jamesbjackson,项目名称:fabio,代码行数:35,代码来源:wsclient.go


示例5: main

func main() {
	flag.StringVar(&url, "u", "", "URL to load test (required)")
	flag.StringVar(&method, "m", "GET", "HTTP method")
	flag.UintVar(&concurrency, "c", 10, "number of concurrent requests")
	flag.UintVar(&requests, "n", 1000, "number of total requests to make")
	flag.UintVar(&timeout, "t", 15, "request timeout in seconds")
	flag.StringVar(&regions, "r", "us-east-1,eu-west-1,ap-northeast-1", "AWS regions to run in (comma separated, no spaces)")
	flag.Parse()

	if url == "" {
		flag.Usage()
		os.Exit(0)
	}

	test, testerr := goad.NewTest(&goad.TestConfig{
		URL:            url,
		Concurrency:    concurrency,
		TotalRequests:  requests,
		RequestTimeout: time.Duration(timeout) * time.Second,
		Regions:        strings.Split(regions, ","),
		Method:         method,
	})
	if testerr != nil {
		fmt.Println(testerr)
		os.Exit(1)
	}

	var finalResult queue.RegionsAggData
	defer printSummary(&finalResult)

	sigChan := make(chan os.Signal, 1)
	signal.Notify(sigChan, syscall.SIGINT, syscall.SIGTERM) // but interrupts from kbd are blocked by termbox

	start(test, &finalResult, sigChan)
}
开发者ID:ernesto-jimenez,项目名称:goad,代码行数:35,代码来源:cli.go


示例6: main

// Main method.
func main() {
	conf := config.New()

	help, version := false, false
	flag.BoolVar(&help, "help", false, "Prints command line options and exit.")
	flag.BoolVar(&version, "version", false, "Prints the etcdsh version and exit.")
	flag.StringVar(&conf.Machine, "machine", conf.Machine, "Connect to this etcd server.")
	flag.StringVar(&conf.PS1, "ps1", conf.PS1, "First prompt format")
	flag.StringVar(&conf.PS2, "ps2", conf.PS2, "Second prompt format")
	flag.BoolVar(&conf.Colors, "colors", conf.Colors, "Use colors in display.")
	flag.Parse()

	if help {
		printHelp()
		os.Exit(0)
	}
	if version {
		printVersion()
		os.Exit(0)
	}

	fmt.Printf("Connecting to %s\n", conf.Machine)
	client := etcd.NewClient([]string{conf.Machine})

	controller := handlers.NewController(conf, client, os.Stdout, os.Stderr, os.Stdin)
	controller.Add(handlers.NewLsHandler(controller))
	controller.Add(handlers.NewSetHandler(controller))
	controller.Add(handlers.NewHelpHandler(controller))
	controller.Add(handlers.NewCdHandler(controller))
	controller.Add(handlers.NewGetHandler(controller))
	os.Exit(controller.Start())
}
开发者ID:headzoo,项目名称:etcdsh,代码行数:33,代码来源:main.go


示例7: New

func New() {
	RootDir = findWorkingDir()

	flag.StringVar(&ApplicationBind, "bind", "localhost:8090", "Host and port to bind to")

	//TODO(kt): handle windows configuration dir
	defaultDataDir := fmt.Sprintf(path.Join(os.Getenv("HOME"), ".config", "sufr", "data"))
	flag.StringVar(&DataDir, "data-dir", defaultDataDir, "Location to store data in")

	defaultTemplateDir := path.Join(RootDir, "templates")
	flag.StringVar(&TemplateDir, "template-dir", defaultTemplateDir, "Location where templates are stored")

	defaultStaticDir := path.Join(RootDir, "static")
	flag.StringVar(&StaticDir, "static-dir", defaultStaticDir, "Location where static assets are stored")

	flag.BoolVar(&Debug, "debug", false, "Turn debugging on")

	flag.Parse()

	if _, err := os.Stat(DataDir); err != nil {
		if os.IsNotExist(err) {
			err := os.MkdirAll(DataDir, os.ModePerm)
			if err != nil {
				panic(err)
			}
		} else {
			panic(err)
		}
	}

	DatabaseFile = path.Join(DataDir, DatabaseName)
}
开发者ID:kyleterry,项目名称:sufr,代码行数:32,代码来源:config.go


示例8: main

func main() {
	// options
	var bind, backend, logTo string
	var buffer uint
	var daemon bool
	flag.StringVar(&bind, "bind", ":8002", "locate ip and port")
	flag.StringVar(&backend, "backend", "127.0.0.1:8003", "backend server ip and port")
	flag.StringVar(&logTo, "logTo", "stdout", "stdout or syslog")
	flag.UintVar(&buffer, "buffer", 4096, "buffer size")
	flag.BoolVar(&daemon, "daemon", false, "run as daemon process")
	flag.Parse()

	log.SetOutput(os.Stdout)
	if logTo == "syslog" {
		w, err := syslog.New(syslog.LOG_INFO, "portproxy")
		if err != nil {
			log.Fatal(err)
		}
		log.SetOutput(w)
	}

	if daemon == true {
		godaemon.MakeDaemon(&godaemon.DaemonAttr{})
	}

	p := New(bind, backend, uint32(buffer))
	log.Println("portproxy started.")
	go p.Start()
	waitSignal()
}
开发者ID:chenzhe07,项目名称:portproxy,代码行数:30,代码来源:main.go


示例9: main

func main() {
	runtime.GOMAXPROCS(runtime.NumCPU())
	var port int
	var size int
	var criteria string
	var index string
	var elastic string
	flag.IntVar(&port, "p", 8080, "HTTP Port")
	flag.IntVar(&size, "s", 10, "LRU Size")
	flag.StringVar(&criteria, "c", "all-criteria", "Criteria File")
	flag.StringVar(&index, "i", "staging1_hotels_id", "Index")
	flag.StringVar(&elastic, "eaddr", "", "Eaddr")
	flag.Parse()
	var s *Sphere
	if elastic == "" {
		s = testSphere(criteria, 50000)
	} else {
		s = loadElastic(index, elastic, criteria)
	}
	cache = newCache(size, s)
	http.HandleFunc("/", httpHander)
	httpAddr := fmt.Sprintf(":%d", port)
	log.Println("Started on ", port)
	log.Fatal(http.ListenAndServe(httpAddr, nil))
}
开发者ID:dreyk,项目名称:dtests,代码行数:25,代码来源:psort.go


示例10: init

func init() {
	flag.StringVar(&RemoteAddress, "remote", "", "")
	flag.StringVar(&RemoteAddress, "r", "", "")

	flag.StringVar(&ServerAddress, "server", "", "")
	flag.StringVar(&ServerAddress, "s", "", "")
}
开发者ID:cloudfoundry-incubator,项目名称:sample-windows-bosh-release,代码行数:7,代码来源:ping-pong.go


示例11: init

func init() {
	flag.BoolVar(&mainInstance.flags.verbose, "verbose", false, "Add verbose log to stderr")
	flag.StringVar(&mainInstance.flags.verboseFile, "verbosefile", "", "Will verbose log to a filename rather than stderr")
	flag.IntVar(&mainInstance.flags.chunkSize, "chunksize", 250, "size to chunk xargs into")
	flag.StringVar(&mainInstance.flags.filenamePrefix, "filename_prefix", "", "Prefix to append to all generated files")
	flag.BoolVar(&mainInstance.flags.forceAbs, "abs", false, "will force abs paths for ... dirs")
}
开发者ID:syenze,项目名称:gobuild,代码行数:7,代码来源:main.go


示例12: main

func main() {
	config := config.Load()

	var chainID string
	var serverAddr string
	var windowSize uint64

	flag.StringVar(&serverAddr, "server", fmt.Sprintf("%s:%d", config.General.ListenAddress, config.General.ListenPort), "The RPC server to connect to.")
	flag.StringVar(&chainID, "chainID", provisional.TestChainID, "The chain ID to deliver from.")
	flag.Uint64Var(&windowSize, "windowSize", 10, "The window size for the deliver.")
	flag.Parse()

	conn, err := grpc.Dial(serverAddr, grpc.WithInsecure())
	if err != nil {
		fmt.Println("Error connecting:", err)
		return
	}
	client, err := ab.NewAtomicBroadcastClient(conn).Deliver(context.TODO())
	if err != nil {
		fmt.Println("Error connecting:", err)
		return
	}

	s := newDeliverClient(client, chainID, windowSize)
	s.seekOldest()
	s.readUntilClose()

}
开发者ID:hyperledger,项目名称:fabric,代码行数:28,代码来源:client.go


示例13: main

// Makes a request for object using CloudFront cookie signing, and outputs
// the contents of the object to stdout.
//
// Usage example:
// signCookies -file <privkey file>  -id <keyId> -r <resource pattern> -g <object to get>
func main() {
	var keyFile string  // Private key PEM file
	var keyID string    // Key pair ID of CloudFront key pair
	var resource string // CloudFront resource pattern
	var object string   // S3 object frontented by CloudFront

	flag.StringVar(&keyFile, "file", "", "private key file")
	flag.StringVar(&keyID, "id", "", "key pair id")
	flag.StringVar(&resource, "r", "", "resource to request")
	flag.StringVar(&object, "g", "", "object to get")
	flag.Parse()

	// Load the PEM file into memory so it can be used by the signer
	privKey, err := sign.LoadPEMPrivKeyFile(keyFile)
	if err != nil {
		fmt.Println("failed to load key,", err)
		return
	}

	// Create the new CookieSigner to get signed cookies for CloudFront
	// resource requests
	signer := sign.NewCookieSigner(keyID, privKey)

	// Get the cookies for the resource. These will be used
	// to make the requests with
	cookies, err := signer.Sign(resource, time.Now().Add(1*time.Hour))
	if err != nil {
		fmt.Println("failed to sign cookies", err)
		return
	}

	// Use the cookies in a http.Client to show how they allow the client
	// to request resources from CloudFront.
	req, err := http.NewRequest("GET", object, nil)
	fmt.Println("Cookies:")
	for _, c := range cookies {
		fmt.Printf("%s=%s;\n", c.Name, c.Value)
		req.AddCookie(c)
	}

	// Send and handle the response. For a successful response the object's
	// content will be written to stdout. The same process could be applied
	// to a http service written cookies to the response but using
	// http.SetCookie(w, c,) on the ResponseWriter.
	resp, err := http.DefaultClient.Do(req)
	if err != nil {
		fmt.Println("failed to send request", err)
		return
	}
	defer resp.Body.Close()

	b, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		fmt.Println("failed to read requested body", err)
		return
	}

	fmt.Println("Response:", resp.Status)
	fmt.Println(string(b))
}
开发者ID:xibz,项目名称:aws-sdk-go,代码行数:65,代码来源:signCookies.go


示例14: argParse

func argParse() {
	flag.StringVar(&options.expr, "expr", "",
		"Specify input file or arithmetic expression string")
	flag.StringVar(&options.json, "json", "",
		"Specify input file or json string")
	flag.Parse()
}
开发者ID:prataprc,项目名称:goparsec,代码行数:7,代码来源:parsec.go


示例15: init

func init() {
	flag.IntVar(&port, "port", 5038, "AMI port")
	flag.StringVar(&host, "host", "localhost", "AMI host")
	flag.StringVar(&user, "user", "admin", "AMI user")
	flag.StringVar(&password, "password", "admin", "AMI secret")
	flag.Parse()
}
开发者ID:vyachin,项目名称:gami,代码行数:7,代码来源:main.go


示例16: main

func main() {
	// parse command line args
	flag.StringVar(&HookfilePath, "file", "config.json", "load hookfile")
	flag.BoolVar(&Debug, "debug", false, "print program debug messages")
	flag.StringVar(&ListenInterface, "interface", "0.0.0.0", "listen interface")
	flag.IntVar(&ListenPort, "port", 8000, "listen TCP port")
	flag.Parse()

	if HookfilePath == "" {
		eprintf("No configuration file specified\n")
		os.Exit(1)
	}

	// load config
	hookfile, err := LoadConfig(HookfilePath)
	if err != nil {
		panic(err)
	}

	rules = hookfile.Rules

	// configure routes
	http.HandleFunc("/", HandleHookRequest)

	// listen
	addr := fmt.Sprintf("%s:%d", ListenInterface, ListenPort)
	printf("starting server on %s\n", addr)
	err = http.ListenAndServe(addr, nil)
	if err != nil {
		panic(err)
	}
}
开发者ID:cavaliercoder,项目名称:gitlab-hook-server,代码行数:32,代码来源:main.go


示例17: init

func init() {
	potentialQueues := os.Getenv("WORKER_QUEUES")
	potentialConcurrency := os.Getenv("WORKER_CONCURRENCY")

	concurrency = 25

	if potentialConcurrency != "" {
		tmp, _ := strconv.ParseInt(potentialConcurrency, 10, 32)
		concurrency = int(tmp)
	}

	flag.StringVar(&queuesString, "queues", potentialQueues, "a comma-separated list of Resque queues")
	flag.Float64Var(&intervalFloat, "interval", 5.0, "sleep interval when no jobs are found")
	flag.IntVar(&concurrency, "concurrency", concurrency, "the maximum number of concurrently executing jobs")
	flag.IntVar(&connections, "connections", 2, "the maximum number of connections to the Redis database")

	redisProvider := os.Getenv("REDIS_PROVIDER")
	var redisEnvUri string
	if redisProvider != "" {
		redisEnvUri = os.Getenv(redisProvider)
	} else {
		redisEnvUri = os.Getenv("REDIS_URL")
	}
	if redisEnvUri == "" {
		redisEnvUri = "redis://localhost:6379/"
	}

	flag.StringVar(&uri, "uri", redisEnvUri, "the URI of the Redis server")
	flag.StringVar(&namespace, "namespace", "resque:", "the Redis namespace")
	flag.BoolVar(&exitOnComplete, "exit-on-complete", false, "exit when the queue is empty")
	flag.BoolVar(&useNumber, "use-number", false, "use json.Number instead of float64 when decoding numbers in JSON. will default to true soon")
}
开发者ID:newrelic-forks,项目名称:goworker,代码行数:32,代码来源:flags.go


示例18: init

func init() {
	flag.StringVar(&etcdServer, "etcd.server", "", "Etcd server")
	flag.StringVar(&graphBackend, "graph.backend", "memory", "Specify the graph backend used")
	flag.StringVar(&storageBackend, "storage.backend", "", "Specify the storage backend used")
	flag.StringVar(&useFlowsConnectionType, "use.FlowsConnectionType", "UDP", "Specify the flows connection type between Agent(s) and Analyzer")
	flag.Parse()
}
开发者ID:skydive-project,项目名称:skydive,代码行数:7,代码来源:helper.go


示例19: main

func main() {
	var iaddr string
	flag.StringVar(&iaddr, "iaddr", "tcp://localhost:5555", "input data port")

	var oaddr string
	flag.StringVar(&oaddr, "oaddr", "tcp://localhost:5556", "output data port")

	flag.Parse()

	isck, err := pull.NewSocket()
	if err != nil {
		log.Fatalf("error creating a nanomsg socket: %v\n", err)
	}
	defer isck.Close()

	isck.AddTransport(ipc.NewTransport())
	isck.AddTransport(tcp.NewTransport())

	osck, err := push.NewSocket()
	if err != nil {
		log.Fatalf("error creating output port: %v\n", err)
	}
	defer osck.Close()

	osck.AddTransport(ipc.NewTransport())
	osck.AddTransport(tcp.NewTransport())

	log.Printf("dialing %s ...\n", iaddr)
	err = isck.Dial(iaddr)
	if err != nil {
		log.Fatalf("error dialing: %v\n", err)
	}
	log.Printf("dialing %s ... [done]\n", iaddr)

	log.Printf("dialing %s ...\n", oaddr)
	err = osck.Dial(oaddr)
	if err != nil {
		log.Fatalf("error dialing: %v\n", err)
	}
	log.Printf("dialing %s ... [done]\n", oaddr)

	for {
		msg, err := isck.Recv()
		if err != nil {
			if err == io.EOF || err == mangos.ErrClosed {
				log.Printf("received EOF: %v\n", err)
				break
			}
			log.Fatalf("error receiving data: %v\n", err)
		}
		log.Printf("recv: %v\n", string(msg))

		omsg := bytes.Repeat(msg, 2)
		err = osck.Send(omsg)
		if err != nil {
			log.Fatalf("error sending data: %v\n", err)
		}
	}

}
开发者ID:mkrzewic,项目名称:FairRoot,代码行数:60,代码来源:main.go


示例20: main

func main() {
	var port int
	var bindAddress string
	var namePrefix string

	flag.StringVar(&bindAddress, "bind", "127.0.0.1",
		"Interface IP to bind to when listening to HTTP connections")
	flag.IntVar(&port, "port", 8912, "Port to listen to for HTTP connections")
	flag.StringVar(&namePrefix, "name-prefix", "mapreduced",
		"Prefix added to the names of all Docker objects created by this")
	flag.Parse()

	if err := controller.Init(namePrefix); err != nil {
		fmt.Println(err)
		os.Exit(1)
	}
	if err := controller.CleanOldState(); err != nil {
		fmt.Println(err)
		os.Exit(1)
	}

	var builder TemplateBuilder
	if err := builder.Init(id, zipReaderAt, zipSize); err != nil {
		return err
	}

}
开发者ID:pwnall,项目名称:mapreduced,代码行数:27,代码来源:mapreduced.go



注:本文中的flag.StringVar函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang flag.Uint函数代码示例发布时间:2022-05-24
下一篇:
Golang flag.String函数代码示例发布时间:2022-05-24
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap