当前位置: 首页>>代码示例>>Golang>>正文


Golang iniflags.Parse函数代码示例

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


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

示例1: main

func main() {
	iniflags.Parse()

	runtime.GOMAXPROCS(*goMaxProcs)

	cache = createCache()
	defer cache.Close()

	upstreamClient = http.Client{
		Transport: &http.Transport{
			MaxIdleConnsPerHost: *maxIdleUpstreamConns,
		},
	}

	var addr string
	for _, addr = range strings.Split(*httpsListenAddrs, ",") {
		go serveHttps(addr)
	}
	for _, addr = range strings.Split(*listenAddrs, ",") {
		go serveHttp(addr)
	}

	waitForeverCh := make(chan int)
	<-waitForeverCh
}
开发者ID:kangkot,项目名称:ybc,代码行数:25,代码来源:main.go

示例2: main

func main() {

	flag.IntVar(&port, "port", 8080, "the port listen to")
	flag.StringVar(&serverName, "server_name", "", "the server name")
	flag.Var(&hosts, "server", "the server connect to")
	flag.StringVar(&docroot, "docroot", ".", "the local http www root")

	iniflags.Parse()

	initRouters()

	if len(hosts) == 0 {
		log.Fatal("you must special a server")
	}
	http2.VerboseLogs = false
	log.Printf("Listening on :%d", port)
	p := &proxy{}
	p.handler = &http2.Transport{
		DialTLS:   p.dialTLS,
		AllowHTTP: true,
	}
	hdr := &myhandler{proxy: p}
	err := http.ListenAndServe(fmt.Sprintf(":%d", port),
		handlers.CombinedLoggingHandler(os.Stdout, hdr))
	if err != nil {
		log.Fatal(err)
	}
}
开发者ID:fangdingjun,项目名称:gpp,代码行数:28,代码来源:local.go

示例3: LoadConfig

func LoadConfig() Config {
	var (
		mongo_user     = flag.String("mongo_user", "", "MongoDB User")
		mongo_pass     = flag.String("mongo_pass", "", "MongoDB Password")
		statsd_host    = flag.String("statsd_host", "localhost", "StatsD Host")
		statsd_port    = flag.Int("statsd_port", 8125, "StatsD Port")
		statsd_env     = flag.String("statsd_env", "dev", "StatsD metric environment prefix")
		statsd_cluster = flag.String("statsd_cluster", "0", "StatsD metric cluster prefix")
		interval       = flag.Duration("interval", 5*time.Second, "Polling interval")
	)

	flag.Var(&mongo_addresses, "mongo_address", "List of mongo addresses in host:port format")
	iniflags.Parse()
	if len(mongo_addresses) == 0 {
		mongo_addresses = append(mongo_addresses, "localhost:27017")
	}
	cfg := Config{
		Interval: *interval,
		Mongo: Mongo{
			Addresses: mongo_addresses,
			User:      *mongo_user,
			Pass:      *mongo_pass,
		},
		Statsd: Statsd{
			Host:    *statsd_host,
			Port:    *statsd_port,
			Env:     *statsd_env,
			Cluster: *statsd_cluster,
		},
	}

	return cfg
}
开发者ID:nod,项目名称:mgo-statsd,代码行数:33,代码来源:config.go

示例4: parse_flags

func parse_flags() {
	iniflags.Parse()

	var err error
	for _, s := range srv {
		sv, err := parse_server(s)
		if err != nil {
			log.Print(err)
		} else {
			Servers = append(Servers, sv)
		}
	}

	for _, dsvr := range default_server {
		proto, addr, err := parse_addr(dsvr)
		if err != nil {
			log.Fatal(err)
		}

		var c *dns.Client
		if proto == "udp" {
			c = client_udp
		} else {
			c = client_tcp
		}

		upsrv := &UpstreamServer{
			Addr:   addr,
			Proto:  proto,
			client: c,
		}
		DefaultServer = append(DefaultServer, upsrv)
	}

	if len(DefaultServer) == 0 {
		log.Fatal("please special a -upstream")
	}

	a, err := load_domain(blacklist_file)
	if err != nil {
		log.Println(err)
	} else {
		Blacklist_ips = a
	}

	if hostfile == "" {
		hostfile = GetHost()
	}

	if hostfile != "" {
		record_hosts, err = ReadHosts(hostfile)
		if err != nil {
			log.Fatal(err)
		}
	}

	if region_file != "" {
		ip_region = parse_net(region_file)
	}
}
开发者ID:fangdingjun,项目名称:gdns,代码行数:60,代码来源:arguments.go

示例5: main

func main() {
	iniflags.Parse()

	backend1 := logging.NewLogBackend(os.Stdout, "", 0)
	backend1Formatter := logging.NewBackendFormatter(backend1, format)
	logging.SetBackend(backend1Formatter)

	//Expand path
	path := *p
	if strings.HasPrefix(*p, "~") {
		usr, _ := user.Current()
		dir := usr.HomeDir
		path = strings.Replace(*p, "~", dir, 1)
	}

	//Run each scraper
	_log.Info("basepath: [%s], scrapers: [%s]", path, *scrapers)
	for _, s := range strings.Split(*scrapers, ",") {
		switch s {
		case "bitstamp":
			handler_wrapper(path, bitstamp.Scrape, "bitstamp")
		case "bitfinex":
			handler_wrapper(path, bitfinex.Scrape, "bitfinex")
		}
	}
}
开发者ID:cryptobase,项目名称:crypto-scraper,代码行数:26,代码来源:main.go

示例6: init

func init() {
	flags()
	iniflags.Parse()
	session, err := mgo.Dial(mongoCS)
	if err != nil {
		panic(err)
	}
	session.SetMode(mgo.Monotonic, true)
	MongoDB = session.DB(mongoName)
}
开发者ID:Nainterceptor,项目名称:MiniProject-Ping,代码行数:10,代码来源:config.go

示例7: main

func main() {
	// set up recovery
	defer recoverPanic()

	// intialize flags
	iniflags.Parse()

	// start web server
	server()
}
开发者ID:seanhagen,项目名称:car-gasoline-tracker,代码行数:10,代码来源:main.go

示例8: main

func main() {
	iniflags.Parse()
	fmt.Printf("Config:\n")
	flag.VisitAll(func(f *flag.Flag) {
		fmt.Printf("%s=%v\n", f.Name, f.Value)
	})
	fmt.Printf("\n")

	rand.Seed(time.Now().UnixNano())
	runtime.GOMAXPROCS(*goMaxProcs)

	serverAddrs_ := strings.Split(*serverAddrs, ",")

	fmt.Printf("Preparing...")
	key = getRandomKey(*keySize)
	value = getRandomValue(*valueSize)

	stats := make([]Stats, *workersCount)
	for i := 0; i < *workersCount; i++ {
		stats[i].responseTimeHistogram = make([]uint32, *responseTimeHistogramSize)
		stats[i].minResponseTime = time.Hour * 24 * 365
	}

	var startTime time.Time
	defer printStats(stats, &startTime)

	var worker func(wg *sync.WaitGroup, ch chan int, stats *Stats)
	switch *clientType {
	case "original":
		worker = getWorkerOrg(serverAddrs_)
	case "new":
		worker = getWorkerNew(serverAddrs_)
	default:
		log.Fatalf("Unknown clientType=[%s]. Expected 'new' or 'original'", *clientType)
	}

	fmt.Printf("done\n")
	fmt.Printf("starting...")
	startTime = time.Now()

	ch := make(chan int, 1000000)
	var wg sync.WaitGroup
	defer wg.Wait()
	for i := 0; i < *workersCount; i++ {
		wg.Add(1)
		go worker(&wg, ch, &stats[i])
	}

	for i := 0; i < *requestsCount; i++ {
		ch <- i
	}
	close(ch)
}
开发者ID:jjoergensen,项目名称:ybc,代码行数:53,代码来源:main.go

示例9: main

func main() {
	iniflags.Parse()

	api := slack.New(*token)

	//var channel_id string
	channel_id := getChannelId(*channel, api)

	var include, exclude *regexp.Regexp
	var err error
	if *includes != "" {
		include, err = regexp.Compile(*includes)
		if err != nil {
			fmt.Println("ERROR: Failed to compile `line_includes` regex.")
			fmt.Println(err)
			api.PostMessage(channel_id, "==> slackd failed to compile `line_includes` regex.", slack.NewPostMessageParameters())
			api.PostMessage(channel_id, err.Error(), slack.NewPostMessageParameters())
			os.Exit(2)
		}
	}
	if *excludes != "" {
		exclude, err = regexp.Compile(*excludes)
		if err != nil {
			fmt.Println("ERROR: Failed to compile `line_excludes` regex.")
			fmt.Println(err)
			api.PostMessage(channel_id, "==> slackd failed to compile `line_excludes` regex.", slack.NewPostMessageParameters())
			api.PostMessage(channel_id, err.Error(), slack.NewPostMessageParameters())
			os.Exit(2)
		}
	}

	log, err := tail.TailFile(*file, tail.Config{Follow: true, ReOpen: *reopen, Poll: true})
	if err != nil {
		fmt.Println("ERROR: Could not tail the specified log.")
		fmt.Println(err)
		api.PostMessage(channel_id, "==> slackd could not tail the specified log.", slack.NewPostMessageParameters())
		api.PostMessage(channel_id, err.Error(), slack.NewPostMessageParameters())
		os.Exit(2)
	}
	for line := range log.Lines {
		if (include != nil && include.MatchString(line.Text)) || (exclude != nil && !exclude.MatchString(line.Text)) {
			api.PostMessage(
				channel_id,
				fmt.Sprintf("```%s```", line.Text),
				slack.NewPostMessageParameters())
		}
	}
}
开发者ID:swill,项目名称:slackd,代码行数:48,代码来源:slackd.go

示例10: main

func main() {
	iniflags.Parse()
	if *showVersion {
		fmt.Println(Commit)
		return
	}
	DB, err = sql.Open(
		"mysql",
		fmt.Sprintf("%s:%[email protected](%s:%s)/mysql", *sqlUser, *sqlPass, *sqlHost, *sqlPort),
	)
	if err != nil {
		log.Fatal(err)
	}
	http.HandleFunc("/", statusHandler)
	http.ListenAndServe(*httpHost+":"+*httpPort, nil)
}
开发者ID:hendrikb,项目名称:galera_watchdog,代码行数:16,代码来源:watchdog.go

示例11: main

func main() {
	iniflags.Parse()

	unixTime = uint64(time.Now().Unix())
	initPow()
	go regenPowChallenges()
	go updateTime()

	loadHtmlFile()
	var addr string
	for _, addr = range strings.Split(*listenAddrs, ",") {
		go serveHttp(addr)
	}

	waitForeverCh := make(chan int)
	<-waitForeverCh
}
开发者ID:Freeaqingme,项目名称:Webjobber,代码行数:17,代码来源:main.go

示例12: main

func main() {
	flag.Set("allowUnknownFlags", "true")
	iniflags.Parse()

	if certPath == nil || len(*certPath) == 0 {
		fmt.Fprintln(os.Stderr, "You must specify a Certificate Path")
		os.Exit(1)
		return
	}

	certFolderDB, err := utils.NewFolderDatabase(*certPath, 0444, *certsPerFolder)
	if err != nil {
		fmt.Fprintln(os.Stderr, fmt.Sprintf("unable to open Certificate Path: %s: %s", certPath, err))
		os.Exit(1)
		return
	}

	if flag.NArg() < 1 {
		fmt.Fprintln(os.Stderr, "Must specify the certificate ID to retrieve")
		os.Exit(1)
		return
	}

	id, err := strconv.ParseUint(flag.Arg(0), 10, 64)
	if err != nil {
		fmt.Fprintln(os.Stderr, fmt.Sprintf("unable to parse as integer: %s", err))
		os.Exit(1)
		return
	}

	data, err := certFolderDB.Get(id)
	if err != nil {
		fmt.Fprintln(os.Stderr, fmt.Sprintf("unable to find CertID: %s", err))
		os.Exit(1)
		return
	}

	_, err = os.Stdout.Write(data)
	if err != nil {
		fmt.Fprintln(os.Stderr, fmt.Sprintf("unable to write out CertID: %s", err))
		os.Exit(1)
		return
	}

}
开发者ID:jcjones,项目名称:ct-sql,代码行数:45,代码来源:get-cert.go

示例13: main

func main() {
	// Parse any set command line flags
	iniflags.Parse()

	config := &Config{iface: *iface, pcapOut: *pcapOut, enableAF: *enableAF, isRunning: true}

	// On ^C or SIGTERM, gracefully stop anything running
	sigc := make(chan os.Signal, 1)
	signal.Notify(sigc, syscall.SIGINT, syscall.SIGTERM)
	go func() {
		<-sigc
		log.Print("Received sigterm/sigint, stopping")
		config.isRunning = false
	}()

	// Open pcap log output
	if err := openPcap(config); err != nil {
		log.Fatal("Error opening pcap file: ", err)
	}
	defer config.pcapFile.Close()

	// Listen on the interface
	var sniffer Sniffer
	if config.enableAF {
		sniffer = &PcapSniffer{}
		log.Print("Using afpacket to sniff packets")
	} else {
		sniffer = &AfpacketSniffer{}
		log.Print("Using libpcap to sniff packets")
	}

	if err := sniffer.Open(config); err != nil {
		log.Fatal("Failed to open the sniffer: ", err)
	}
	config.sniffer = sniffer
	defer config.sniffer.Close()
	log.Printf("Listening on %s\n", config.iface)

	if err := Listen(config); err != nil {
		log.Fatal("Listening stopped with an error: ", err)
	}

	log.Print("Successful exit")
}
开发者ID:postfix,项目名称:sniffer,代码行数:44,代码来源:main.go

示例14: main

func main() {
	iniflags.Parse()
	flag.VisitAll(func(f *flag.Flag) {
		fmt.Printf("%s=%v\n", f.Name, f.Value)
	})

	runtime.GOMAXPROCS(*goMaxProcs)

	testUri, err := url.Parse(*testUrl)
	if err != nil {
		log.Fatalf("Error=[%s] when parsing testUrl=[%s]\n", err, *testUrl)
	}

	ch := make(chan int, 100000)
	bytesRead := make([]int64, *workersCount)
	wg := &sync.WaitGroup{}

	for i := 0; i < *workersCount; i++ {
		wg.Add(1)
		go worker(ch, wg, testUri, &bytesRead[i])
	}

	log.Printf("Test started\n")
	startTime := time.Now()
	for i := 0; i < *requestsCount; i++ {
		ch <- 1
	}
	close(ch)
	wg.Wait()
	duration := time.Since(startTime)
	seconds := float64(duration) / float64(time.Second)

	var totalBytesRead int64
	for i := 0; i < *workersCount; i++ {
		totalBytesRead += bytesRead[i]
	}
	kbytesRead := float64(totalBytesRead) / float64(1000)
	qps := float64(*requestsCount) / seconds
	kbps := kbytesRead / seconds
	log.Printf("Done\n")
	log.Printf("%d requests from %d workers in %s\n", *requestsCount, *workersCount, duration)
	log.Printf("%.0f Kbytes read, %.0f qps, %.0f Kbps\n", kbytesRead, qps, kbps)
}
开发者ID:valyala,项目名称:ybc,代码行数:43,代码来源:main.go

示例15: main

func main() {
	iniflags.Parse()

	// Set up logging
	if lw, err := NewLogWatch(); err != nil {
		log.Printf("[flag -logfile] '%s' will carry on without the logfile\n", err)
	} else {
		http.Handle("/tail1000", lw)
	}

	if config.TrimQueries {
		log.Printf("Testing stemming: '%s'\n", StemQuery("I like to stemming my queries"))
		// This is a function rather an an init, as it relies of the results of the flags
		LoadImportance()
		log.Println(TrimQuery("This is a stemming queries that needs a bit of a trim dream babies"))
	}
	// Create a liveQA
	lqa := NewLiveQA()

	// Add answer producers
	count := 0
	for _, name := range config.Producers {
		if f, ok := factory[name]; ok {
			ap, err := f(name + ".json")
			if err != nil {
				log.Printf("[Error initialising %s] %s\n", name, err)
			} else {
				lqa.AddProducer(ap)
				log.Printf("Initialised '%s' answer producer\n", name)
				count++
			}
		} else {
			log.Printf("[Error initialising %s] Unrecognised answer producer '%s'\n", name, name)
		}
	}
	log.Printf("Initialised %d of %d total answer producers\n", count, len(config.Producers))

	http.Handle("/", lqa)

	log.Fatal(http.ListenAndServe(":"+strconv.Itoa(config.Port), nil))
}
开发者ID:TimothyJones,项目名称:trec-liveqa-server,代码行数:41,代码来源:main.go


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