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


Golang flag.Int64函数代码示例

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


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

示例1: 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

示例2: main

func main() {
	total := flag.Int64("total", 0, "Total block size in MB")
	block := flag.Int64("block", 100, "block init size in MB [dd bs]. count will be 1")
	parallel := flag.Int64("parallel", 2, "size")
	device := flag.String("device", "/dev/xvdf", "name")
	offset := flag.Int64("offset", 0, "starting offset that will be used to skip")

	flag.Parse()

	p := make(chan bool, *parallel)

	c := *offset
	for c*(*block) < *total {
		go func(c int64) {
			ifd := fmt.Sprintf("if=%s", *device)
			of := fmt.Sprintf("of=/dev/null")
			bs := fmt.Sprintf("bs=%dM", *block)
			count := fmt.Sprintf("count=1")
			skip := fmt.Sprintf("skip=%d", c)
			out, err := exec.Command("dd", ifd, of, bs, count, skip).CombinedOutput()
			if err != nil {
				log.Println(err, out)
			}
			<-p
		}(c)
		p <- true
		c++
		fmt.Println("offset:", c, "total:", c*(*block), "MB")
	}

	for i := int64(0); i < *parallel; i++ {
		p <- true
	}
}
开发者ID:kavehmz,项目名称:garbage,代码行数:34,代码来源:main.go

示例3: main

func main() {

	lat := flag.Float64("lat", 0, "latitude of occurrence")
	lng := flag.Float64("lng", 0, "longitude of occurrence")
	explain := flag.Bool("explain", true, "print useful information")
	date := flag.Int64("date", 0, "unix second: 1467558491")
	period := flag.Int64("period", 14, "number of days into the past to generate weather: 14")

	flag.Parse()

	store, err := noaa.NewWeatherStore(
		"/Users/mph/Desktop/phenograph-raw-data/stations.txt",
		"/Users/mph/Desktop/phenograph-raw-data/ghcnd_all/ghcnd_all",
		false,
	)
	if err != nil {
		panic(err)
	}

	records, err := store.Nearest(
		*lat,
		*lng,
		noaa.Elements{noaa.ElementTMAX, noaa.ElementPRCP, noaa.ElementTMIN},
		noaa.TimesFromUnixArray(*date, *period),
		*explain,
	)
	if err != nil {
		panic(err)
	}

	fmt.Println("RECORDS", utils.JsonOrSpew(records))

	return
}
开发者ID:heindl,项目名称:raincollector,代码行数:34,代码来源:main.go

示例4: main

func main() {
	// get all the vars
	numNewpix := flag.Int64("numnewpix", -1, "Mandatory -- The number of NewPix to click for, 0 for infinite, negative for displaying help.")
	xserver := flag.String("xserver", os.Getenv("DISPLAY"), "Which X server to send the clicks to (defaults to the one this command is ran from).")
	startpix := flag.Int64("currentpix", 1, "Which pix the game is on.")
	npbotmNP := flag.Int64("npbotmnp", 400, "How many mNP the NewPixBots need to avoid being ninja'd (0 if there's no ninja).")
	helpwanted := flag.Bool("help", false, "Print the help message.")
	flag.Parse()

	// verify parameter validity and display help if anything's invalid (or if help's requested)
	if *helpwanted || *numNewpix < 0 || *startpix < 1 || *npbotmNP < 0 {
		usage()
		os.Exit(1)
	}

	// make clicker
	ch := make(chan bool, 1)
	go cmdRepeater(ch, func() *exec.Cmd { return clickNCmd(5, *xserver) })

	// finish current newpix
	curpix := *startpix
	var margin int64 = 3 // how many extra mNP on either side of newpixbot ninja'ing time to wait
	wakemNP := *npbotmNP + margin
	sleepmNP := 1000 - margin
	if mNP := currentmNP(curpix); mNP < sleepmNP {
		clickLoopIteration(curpix, wakemNP, sleepmNP, ch)
	}
	for curpix++; curpix < *startpix+*numNewpix; curpix++ {
		clickLoopIteration(curpix, wakemNP, sleepmNP, ch)
	}
}
开发者ID:refola,项目名称:golang,代码行数:31,代码来源:sandclick.go

示例5: main

func main() {
	providersFile := flag.String("providers_file", "providers.json", "Path to oembed providers json file")
	workerCount := flag.Int64("worker_count", 1000, "Amount of workers to start")
	host := flag.String("host", "localhost", "Host to listen on")
	port := flag.Int("port", 8000, "Port to listen on")
	maxHTMLBytesToRead := flag.Int64("html_bytes_to_read", 50000, "How much data to read from URL if it's an html page")
	maxBinaryBytesToRead := flag.Int64("binary_bytes_to_read", 4096, "How much data to read from URL if it's NOT an html page")
	waitTimeout := flag.Int("wait_timeout", 7, "How much time to wait for/fetch response from remote server")
	whiteListRanges := flag.String("whitelist_ranges", "", "What IP ranges to allow. Example: 178.25.32.1/8")
	blackListRanges := flag.String("blacklist_ranges", "", "What IP ranges to disallow. Example: 178.25.32.1/8")

	flag.Parse()

	buf, err := ioutil.ReadFile(*providersFile)

	if err != nil {
		panic(err)
	}

	var whiteListNetworks []*net.IPNet
	if len(*whiteListRanges) > 0 {
		if whiteListNetworks, err = stringsToNetworks(strings.Split(*whiteListRanges, " ")); err != nil {
			panic(err)
		}
	}

	var blackListNetworks []*net.IPNet
	if len(*blackListRanges) > 0 {
		if blackListNetworks, err = stringsToNetworks(strings.Split(*blackListRanges, " ")); err != nil {
			panic(err)
		}
	}

	oe := oembed.NewOembed()
	oe.ParseProviders(bytes.NewReader(buf))

	workers := make([]tunny.TunnyWorker, *workerCount)
	for i := range workers {
		p := url2oembed.NewParser(oe)
		p.MaxHTMLBodySize = *maxHTMLBytesToRead
		p.MaxBinaryBodySize = *maxBinaryBytesToRead
		p.WaitTimeout = time.Duration(*waitTimeout) * time.Second
		p.BlacklistedIPNetworks = blackListNetworks
		p.WhitelistedIPNetworks = whiteListNetworks
		workers[i] = &(apiWorker{Parser: p})
	}

	pool, err := tunny.CreateCustomPool(workers).Open()

	if err != nil {
		log.Fatal(err)
	}

	defer pool.Close()

	workerPool = pool

	startServer(*host, *port, *waitTimeout)
}
开发者ID:undefzx,项目名称:proclink-api,代码行数:59,代码来源:server.go

示例6: init

func init() {
	depthPtr = flag.Int64("depth", 50, "sets the number of rows (and hash functions) in the CMSketch")
	widthPtr = flag.Int64("width", 80, "sets the number of columns in the CMSketch")
	efactorPtr = flag.Int64("efactor", 10, "number of elements = depth*width*efactor")
	NumProcsPtr := flag.Int64("procs", 1, "number of concurrent worker processes")
	flag.Parse()
	numProcs = *NumProcsPtr
}
开发者ID:jpfairbanks,项目名称:cse6140,代码行数:8,代码来源:main.go

示例7: main

func main() {
	channel_pairs := flag.Int("channel_pairs", 4, "channel_pairs")
	count := flag.Int64("count", 1000000, "iterations")
	blocking_count := flag.Int64("blocking_count", 10000, "blocking iterations")
	flag.Parse()
	run_test("buffer = 1024", *channel_pairs, 1024, *count)
	run_test("blocking", *channel_pairs, 0, *blocking_count)
}
开发者ID:brianwatling,项目名称:elbowroom,代码行数:8,代码来源:channel_bench.go

示例8: main

func main() {
	queryPtr := flag.String("query", "", "Query to run. E.g. \"MAP field_1, field_2 REDUCE ON field_1\"")
	startPtr := flag.Int64("start", 0, "Start date (in seconds)")
	endPtr := flag.Int64("end", time.Now().Unix(), "End date (in seconds)")
	flag.Parse()
	startTm := time.Unix(*startPtr, 0)
	endTm := time.Unix(*endPtr, 0)
	startFile := GenerateFileName(startTm)
	endFile := GenerateFileName(endTm)
	dirname := "data" + string(filepath.Separator)

	query := bytes.NewBufferString(*queryPtr)
	p := NewParser(query)
	mapper, reducer, err := p.Parse()
	if err != nil {
		panic(err)
	}

	d, err := os.Open(dirname)
	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}

	defer d.Close()

	files, err := d.Readdir(-1)
	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}

	for _, f := range files {
		if startFile <= f.Name() && f.Name() <= endFile {
			if file, err := os.Open(dirname + f.Name()); err == nil {
				scanFile(file, mapper)
			} else {
				log.Fatal(err)
			}
		}
	}

	if reducer.Key == "" {
		if resultStr, err := json.Marshal(mapped); err != nil {
			panic(err)
		} else {
			fmt.Printf("%s", resultStr)
		}
	} else {
		_reduce(*reducer)
		if resultStr, err := json.Marshal(reduced); err != nil {
			panic(err)
		} else {
			fmt.Printf("%s", resultStr)
		}
	}
}
开发者ID:jbwyme,项目名称:gofigure,代码行数:57,代码来源:query.go

示例9: parseFlags

func parseFlags() (load, blockSize *float64, numBlocks, numIterations *int64) {
	load = flag.Float64("load", 0.0, "load percentage")
	blockSize = flag.Float64("bs", bls.DEFAULT_BLOCK_SIZE, "block size")
	numBlocks = flag.Int64("nb", bls.DEFAULT_NUM_BLOCKS, "number of blocks")
	numIterations = flag.Int64("ni", bls.DEFAULT_NUM_ITERATIONS, "number of iterations")

	flag.Parse()
	return
}
开发者ID:cfromknecht,项目名称:bitcoin_load_spike,代码行数:9,代码来源:main.go

示例10: get_cli

func get_cli() (*prefs, bool) {
	def_streams := int64(runtime.NumCPU())
	preferences := &prefs{}
	encryptCmd := flag.Bool("encrypt", false, "")
	decryptCmd := flag.Bool("decrypt", false, "")
	streams := flag.Int64("s", def_streams, "Num of streams")
	filename := flag.String("f", "", "File need to encrypt/decrypt")
	chunk_size := flag.Int64("c", 1, "Size of chunk in Kb")
	key := flag.String("k", "", "Key file, required for decryption")
	output := flag.String("o", "", "Resulting file")
	flag.Parse()

	if *encryptCmd && !*decryptCmd {
		preferences.Command = ENCRYPT_CMD
	} else if *decryptCmd && !*encryptCmd {
		preferences.Command = DECRYPT_CMD
	} else {
		fmt.Println("You have to choose decrypt or encrypt command!")
		return nil, false
	}

	if _, err := os.Stat(*filename); len(*filename) == 0 || os.IsNotExist(err) {
		fmt.Printf("Invalid input file path %q\n\t%v\n", *filename, err)
		return nil, false
	}
	preferences.Filename = *filename

	if *streams <= 0 {
		*streams = def_streams
	}
	preferences.Streams = *streams

	if *chunk_size <= 0 {
		fmt.Println("Chunk size has to be more then 0")
		return nil, false
	}
	preferences.Chunk_Size = (*chunk_size) * pow_int64(2, 10)

	if len(*key) == 0 {
		fmt.Println("Invalid keyfile path")
		return nil, false
	}
	preferences.KeyFilename = *key

	if len(*output) == 0 {
		fmt.Println("Invalid resulting file path")
		return nil, false
	}
	preferences.OutputFilename = *output

	file_info, err := os.Stat(preferences.Filename)
	check(err)
	preferences.FileLen = file_info.Size()

	return preferences, true
}
开发者ID:ninedraft,项目名称:xorefy,代码行数:56,代码来源:cli.go

示例11: main

func main() {
	num := flag.Int64("num", 0, "number of numbers")
	max := flag.Int64("max", 0, "max number")
	flag.Parse()

	r := rand.New(rand.NewSource(1))
	i := int64(0)
	for i = 0; i < *num; i++ {
		fmt.Printf("%d\n", r.Int63n(*max+1))
	}

	return
}
开发者ID:feeblefakie,项目名称:tools,代码行数:13,代码来源:go_rnd.go

示例12: Flag

// 获取外部参数
func Flag() {
	// 分类说明
	flag.String("c . . . . . . . . . . . . .. . . . . . . . . . . only for cmd . . . . . . . . . . . . . .. . . . . . . . . . c", "cmd", "\r\n")

	// 自定义输入
	keywordflag = flag.String("c_keyword", "", "   <自定义输入 选填 多关键词以 \",\" 隔开>")

	// 蜘蛛列表
	spiderflag = flag.String("c_spider", "", func() string {
		var spiderlist string
		for k, v := range app.LogicApp.GetSpiderLib() {
			spiderlist += "   {" + strconv.Itoa(k) + "} " + v.GetName() + "  " + v.GetDescription() + "\r\n"
		}
		return "   <蜘蛛列表 选择多蜘蛛以 \",\" 间隔>\r\n" + spiderlist
	}())

	// 输出方式
	outputflag = flag.String("c_output", app.LogicApp.GetOutputLib()[0], func() string {
		var outputlib string
		for _, v := range app.LogicApp.GetOutputLib() {
			outputlib += "{" + v + "} "
		}
		return "   <输出方式> " + strings.TrimRight(outputlib, " ")
	}())

	// 并发协程数
	threadflag = flag.Int("c_thread", cache.Task.ThreadNum, "   <并发协程> {1~99999}\n")

	// 平均暂停时间
	pauseflag = flag.Int64("c_pause", cache.Task.Pausetime, "   <平均暂停时间/ms> {>=100} ")

	// 代理IP更换频率
	proxyflag = flag.Int64("c_proxy", cache.Task.ProxyMinute, "   <代理IP更换频率/m 为0时不使用代理> {>=0} ")

	// 分批输出
	dockerflag = flag.Int("c_docker", cache.Task.DockerCap, "   <分批输出> {1~5000000}")

	// 采集页数
	maxpageflag = flag.Int64("c_maxpage", 0, "   <采集页数> {>=0}")

	// 继承之前的去重记录
	successInheritflag = flag.Bool("c_inherit_y", true, "   <继承并保存成功记录 {true/false}>")
	failureInheritflag = flag.Bool("c_inherit_n", true, "   <继承并保存失败记录 {true/false}>")

	// 备注说明
	flag.String(
		"c_z",
		"cmd-example",
		" pholcus -a_ui=cmd -c_spider=3,8 -c_output=csv -c_thread=20 -c_docker=5000 -c_pause=300 -c_proxy=0 -c_keyword=pholcus,golang -c_maxpage=10 -c_inherit_y=true -c_inherit_n=true\r\n",
	)
}
开发者ID:Cdim,项目名称:pholcus,代码行数:52,代码来源:pholcus-cmd.go

示例13: main

func main() {
	var port = flag.Int("port", 80, `port, default is 80`)
	var isDebug = flag.Bool("debug", false, `debug, default is false`)
	var centerId = flag.Int64("center", 0, `centerId, default is 0`)
	var workerId = flag.Int64("worker", 0, `workerId, default is 0`)
	var twepoch = flag.Int64("twepoch", 0, `twepoch, default is 0`)
	flag.Parse()

	generator, _ = id.NewId(*workerId, *centerId, *twepoch)
	colorize.IsDebug = *isDebug
	colorize.Info(`going to run :%d`, *port)

	http.HandleFunc("/", RequestHanler)
	http.ListenAndServe(fmt.Sprintf(":%d", *port), nil)
}
开发者ID:maigoxin,项目名称:snowflake,代码行数:15,代码来源:snowflake.go

示例14: main

func main() {
	// get command line flags
	coresToPegPtr = flag.Int64("coresToPeg", 0, "how many CPU cores would you like to artificially peg to 100% usage")

	flag.Parse()

	// this will help us poll the OS to get system statistics
	stats := NewStats()

	runtime.GOMAXPROCS(runtime.NumCPU())

	// WARNING: each call to burnCPU() will peg one core
	// of your machine to 100%
	// If you have code you'd like to drop in to this example,
	// just run "go yourCode()" instead of "go burnCPU()
	for i := *coresToPegPtr; i > 0; i-- {
		fmt.Println("pegging one more CPU core.")
		go burnCPU()
	}

	for {
		stats.GatherStats(true)
		stats.PrintStats()

		// This next line lets out see the jsonified object
		// produced by systemstat
		//	printJson(stats, false)
		time.Sleep(3 * time.Second)
	}
}
开发者ID:Clarifai,项目名称:kubernetes,代码行数:30,代码来源:go-top.go

示例15: init

func init() {
	atomSizeUsage := "atom size (1, 2, or 3)"
	atomSize := flag.Uint("atomsize", 1, atomSizeUsage)

	carrierUsage := "path to message carrier"
	carrier := flag.String("carrier", "", carrierUsage)

	inputUsage := "path to input; can be - for standard in"
	input := flag.String("input", "-", inputUsage)

	boxUsage := "use size-checking encapsulation format"
	box := flag.Bool("box", false, boxUsage)

	offsetUsage := "read/write offset"
	offset := flag.Int64("offset", 0, offsetUsage)

	flag.Parse()

	if *atomSize < 1 || *atomSize > 3 {
		log.Fatalf("atom size must be 1, 2, or 3")
	}

	if *offset < 0 {
		log.Fatalf("offset must be positive")
	}

	state = new(cmd.State)
	state.Ctx = steg.NewCtx(uint8(*atomSize))
	state.Carrier, state.CarrierSize = getCarrier(*carrier)
	state.Input, state.InputSize = getInput(*input)
	state.Box = *box
	state.Offset = *offset
}
开发者ID:pennello,项目名称:go_steg,代码行数:33,代码来源:main.go


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