本文整理汇总了Golang中flag.Int64Var函数的典型用法代码示例。如果您正苦于以下问题:Golang Int64Var函数的具体用法?Golang Int64Var怎么用?Golang Int64Var使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Int64Var函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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()
}
示例2: main
func main() {
var options Options
flag.Var(&options.SourceDirs, "folder", "The folder to inspect for documents, can be provided multiple times")
flag.StringVar(&options.Agency, "agency", "", "The agency to use if it's not available in the folder structure")
flag.StringVar(&options.Component, "component", "", "The component to use if it's not available in the folder structure")
flag.StringVar(&options.HtmlReport, "report", "report.html", "The file in which to store the HTML report")
flag.StringVar(&options.PhpDataFile, "phpDataFile", "", "The file in which to store the file information as PHP data")
flag.StringVar(&options.PhpVarName, "phpVarName", "$FILES", "The PHP variable to assign the file data to")
flag.BoolVar(&options.WarnOnMissingAgency, "warnOnMissingAgency", false, "Should we warn if a agency is missing from folder structure?")
flag.BoolVar(&options.WarnOnMissingComponent, "warnOnMissingComponent", false, "Should we warn if a component is missing from folder structure?")
flag.Int64Var(&options.ErrorSingleFileSizeBytes, "errorSingleFileSizeBytes", 1024*500, "Display an error for any files larger than this size")
flag.Int64Var(&options.WarnAverageFileSizeBytes, "warnAverageFileSizeBytes", 1024*384, "Display a warning if average size of files in the download exceeds this threshold")
//options.SourceDirs.Set("C:\\Projects\\MAX-OGE\\docs-generator\\generated-files")
options.Extensions = map[string]bool{".pdf": true}
options.FieldsSeparator = ';'
if options.validate() {
var results Results
results.Options = options
results.walkSourceDirs()
fmt.Println(results.LastFileIndex, "documents found in", len(results.DirsWalked), "folders.")
results.createReport("HTML Report", htmlReportTemplate, options.HtmlReport)
if len(options.PhpDataFile) > 0 {
results.createReport("PHP Data", phpDataTemplate, options.PhpDataFile)
}
}
}
示例3: main
func main() {
flag.StringVar(&target.Address, "a", "", "address of sink")
flag.Int64Var(&target.Counter, "c", 0, "initial packet counter")
flag.Int64Var(&target.Next, "t", 0, "initial update timestamp")
keyFile := flag.String("k", "decrypt.pub", "sink's decryption public key")
flag.Parse()
if target.Address == "" {
fmt.Fprintf(os.Stderr, "[!] no address provided.\n")
os.Exit(1)
}
in, err := ioutil.ReadFile(*keyFile)
checkError(err)
if len(in) != 32 {
fmt.Fprintf(os.Stderr, "[!] invalid Curve25519 public key.\n")
}
target.Public = in
buf := &bytes.Buffer{}
out, err := json.Marshal(target)
checkError(err)
err = json.Indent(buf, out, "", "\t")
checkError(err)
fmt.Printf("%s\n", buf.Bytes())
}
示例4: init
func init() {
flag.Int64Var(&first, "first", 0, "first uid")
flag.Int64Var(&last, "last", 0, "last uid")
flag.StringVar(&local_ip, "local_ip", "0.0.0.0", "local ip")
flag.StringVar(&host, "host", "127.0.0.1", "host")
flag.IntVar(&port, "port", 23000, "port")
}
示例5: main
func main() {
var (
S_SERVERS string
S_LISTEN string
S_ACCESS string
timeout int
max_entries int64
expire_interval int64
)
flag.StringVar(&S_SERVERS, "proxy", "127.0.0.1:53", "we proxy requests to those servers")
flag.StringVar(&S_LISTEN, "listen", "[::1]:5353,127.0.0.1:5353",
"listen on (both tcp and udp), [ipv6address]:port, ipv4address:port")
flag.StringVar(&S_ACCESS, "access", "0.0.0.0/0", "allow those networks, use 0.0.0.0/0 to allow everything")
flag.IntVar(&timeout, "timeout", 5, "timeout")
flag.Int64Var(&expire_interval, "expire_interval", 300, "delete expired entries every N seconds")
flag.BoolVar(&DEBUG, "debug", false, "enable/disable debug")
flag.Int64Var(&max_entries, "max_cache_entries", 2000000, "max cache entries")
flag.Parse()
servers := strings.Split(S_SERVERS, ",")
proxyer := ServerProxy{
giant: new(sync.RWMutex),
ACCESS: make([]*net.IPNet, 0),
SERVERS: servers,
s_len: len(servers),
NOW: time.Now().UTC().Unix(),
entries: 0,
timeout: time.Duration(timeout) * time.Second,
max_entries: max_entries}
for _, mask := range strings.Split(S_ACCESS, ",") {
_, cidr, err := net.ParseCIDR(mask)
if err != nil {
panic(err)
}
_D("added access for %s\n", mask)
proxyer.ACCESS = append(proxyer.ACCESS, cidr)
}
for _, addr := range strings.Split(S_LISTEN, ",") {
_D("listening @ :%s\n", addr)
go func() {
if err := dns.ListenAndServe(addr, "udp", proxyer); err != nil {
log.Fatal(err)
}
}()
go func() {
if err := dns.ListenAndServe(addr, "tcp", proxyer); err != nil {
log.Fatal(err)
}
}()
}
for {
proxyer.NOW = time.Now().UTC().Unix()
time.Sleep(time.Duration(1) * time.Second)
}
}
示例6: main
func main() {
dev := flag.String("d", "/dev/input/by-id/usb-0810_Twin_USB_Joystick-event-joystick", "The GH controller event device")
flag.Int64Var(&baseNote, "b", 48, "The base midi note with no button pressed")
flag.Int64Var(&vel, "v", 100, "Midi note velocity")
flag.Int64Var(&midiChan, "c", 1, "Midi channel")
flag.Parse()
portmidi.Initialize()
out, err := portmidi.NewOutputStream(portmidi.GetDefaultOutputDeviceId(), 32, 0)
if err != nil {
fmt.Println(err)
return
}
c := make(chan *evdev.InputEvent)
e := make(chan error)
go ReadGuitar(c, e, *dev)
for {
select {
case but := <-c:
switch but.Code {
case butGreen, butRed, butYellow, butBlue, butOrange:
SetNote(butMap[but.Code], but.Value)
if playing != -1 {
SwapNote(out, baseNote+butState+octave, vel)
}
case butStrumbar:
if but.Value == 255 || but.Value == 0 {
NoteOn(out, baseNote+butState+octave, vel)
} else if !hold {
NoteOff(out, playing, vel)
}
case butSelect:
if but.Value != 0 {
hold = !hold
if !hold {
NoteOff(out, playing, vel)
}
}
case butTilt:
if but.Value == 1 {
octave += 12
} else {
octave -= 12
}
if playing != -1 {
SwapNote(out, baseNote+butState+octave, vel)
}
case butStart:
AllNotesOff(out)
}
case err := <-e:
fmt.Println(err)
close(c)
close(e)
return
default:
}
}
}
示例7: init
func init() {
flag.StringVar(&topic, "topic", "sangrenel", "Topic to publish to")
flag.Int64Var(&msgSize, "size", 300, "Message size in bytes")
flag.Int64Var(&msgRate, "rate", 100000000, "Apply a global message rate limit")
flag.IntVar(&batchSize, "batch", 0, "Max messages per batch. Defaults to unlimited (0).")
flag.StringVar(&compressionOpt, "compression", "none", "Message compression: none, gzip, snappy")
flag.BoolVar(&noop, "noop", false, "Test message generation performance, do not transmit messages")
flag.IntVar(&clients, "clients", 1, "Number of Kafka client workers")
flag.IntVar(&producers, "producers", 5, "Number of producer instances per client")
brokerString := flag.String("brokers", "localhost:9092", "Comma delimited list of Kafka brokers")
flag.Parse()
brokers = strings.Split(*brokerString, ",")
switch compressionOpt {
case "gzip":
compression = kafka.CompressionGZIP
case "snappy":
compression = kafka.CompressionSnappy
case "none":
compression = kafka.CompressionNone
default:
fmt.Printf("Invalid compression option: %s\n", compressionOpt)
os.Exit(1)
}
sentCntr <- 0
runtime.GOMAXPROCS(runtime.NumCPU())
}
示例8: MakeConfigFromCmdline
func MakeConfigFromCmdline() *Config {
tc := &Config{}
flag.StringVar(&tc.ClientType, "client_type", "consul", "Type of client to connect with")
flag.StringVar(&tc.BenchType, "bench_type", "read", "Type of test to run")
flag.BoolVar(&tc.Setup, "setup", false, "Initialize the servers for test type")
flag.Int64Var(&tc.Iterations, "iterations", 10, "Number of times to read")
flag.Float64Var(&tc.ArrivalRate, "arrival_rate", 2, "Number of operations per second")
flag.Int64Var(&tc.Seed, "seed", time.Now().UnixNano(), "Random number seed (defaults to current nanoseconds)")
flag.BoolVar(&tc.Debug, "debug", false, "Enable verbose output")
flag.StringVar(&tc.ServerHost, "server_host", "", "Override of server host:port")
flag.Parse()
if tc.ClientType != "consul" &&
tc.ClientType != "etcd" &&
tc.ClientType != "zookeeper" {
fmt.Printf("Error: invalid client_type '%s'\n", tc.ClientType)
}
if tc.Debug {
fmt.Printf("server_type = %s\n", tc.ClientType)
fmt.Printf("server_host = %s\n", tc.ServerHost)
fmt.Printf("setup = %t\n", tc.Setup)
fmt.Printf("bench_type = %s\n", tc.BenchType)
fmt.Printf("iterations = %d\n", tc.Iterations)
fmt.Printf("arrival_rate = %f\n", tc.ArrivalRate)
fmt.Printf("seed = %d\n", tc.Seed)
fmt.Printf("debug = %t\n", tc.Debug)
}
return tc
}
示例9: init
func init() {
flag.StringVar(&username, "username", os.Getenv("HIVEKIT_USER"), "Hive Home web service username (usually an email address)")
flag.StringVar(&password, "password", os.Getenv("HIVEKIT_PASS"), "Hive Home web service password")
flag.StringVar(&pin, "pin", os.Getenv("HIVEKIT_PIN"), "The HomeKit accessory pin (8 numeric chars)")
flag.BoolVar(&verbose, "verbose", false, "Enable verbose logging")
flag.Int64Var(&boostDuration, "boost-duration", 60, "Duration (minutes) to boost heating")
flag.Int64Var(&hotWaterDuration, "boost-water", 60, "Duration (minutes) to boost hot water")
}
示例10: init
func init() {
flag.Int64Var(&count, "count", 100, "files to generate")
flag.Int64Var(&sizeMax, "size-max", 1024*100, "maximum file size in bytes")
flag.Int64Var(&sizeMin, "size-min", 1024*5, "minimum file size in bytes")
flag.IntVar(&resMax, "res-max", 1980, "maximum ephemeral resolution")
flag.IntVar(&resMin, "res-min", 500, "minumum ephemeral resolution")
flag.IntVar(&workers, "workers", 1, "concurrent workers")
flag.StringVar(&dir, "dir", "", "working directory")
}
示例11: parseFlags
func parseFlags() {
flag.StringVar(&flagHTTPAddr, "http", flagHTTPAddr, "HTTP addr")
flag.StringVar(&flagGitHubWebhookSecret, "github-webhook-secret", flagGitHubWebhookSecret, "GitHub webhook secret")
flag.Int64Var(&flagGroupcache, "groupcache", flagGroupcache, "Groupcache")
flag.StringVar(&flagGroupcacheSelf, "groupcache-self", flagGroupcacheSelf, "Groupcache self")
flag.StringVar(&flagGroupcachePeers, "groupcache-peers", flagGroupcachePeers, "Groupcache peers")
flag.Int64Var(&flagCacheMemory, "cache-memory", flagCacheMemory, "Cache memory")
flag.Parse()
}
示例12: init
func init() {
flag.StringVar(&httpHost, "host", "0.0.0.0", "Host to bind HTTP server to")
flag.StringVar(&httpPort, "port", "1080", "Port to bind HTTP server to")
flag.Int64Var(&maxSize, "max-size", 0, "Maximum size of uploads in bytes")
flag.StringVar(&dir, "dir", "./data", "Directory to store uploads in")
flag.Int64Var(&storeSize, "store-size", 0, "Size of disk space allowed to storage")
flag.StringVar(&basepath, "base-path", "/files/", "Basepath of the hTTP server")
flag.Parse()
}
示例13: init
func init() {
flag.StringVar(&Mode, "mode", "client", "client/server, start as client or server mode")
flag.StringVar(&ServerUrl, "server", "http://www.baidu.com", "client mode: assign server url to test")
flag.Int64Var(&DurationSec, "ds", 1, "client mode: request duration (milli sec)")
flag.Int64Var(&DurationMilliSec, "dms", 100, "client mode: request duration (sec), it will replace DurationMilliSec")
flag.Int64Var(&IntervalMilliSec, "ims", 10, "client mode: request interval (milli sec)")
flag.StringVar(&FileSize, "filesize", "10m", "file size when request \"/\" url, default 10MB, k/kb/m/mb/g/gb all accepted")
flag.Parse()
}
示例14: main
func main() {
//
// The purpose of this program is to demonstrate that when CloseWrite is called on a connection
// opened across the loopback interface that received (but not acknowledged) packets will be
// be acknowledged with an incorrect ack sequence number and so prevent the arrival of
// packets sent after that time.
//
// The server waits for connections on the specified interface and port.
// When it receives a connection it reads parameters from the connection. The parameters are:
// * the number of bytes in each burst
// * the number of milliseconds to delay between each burst
// * the number of bursts to generate
//
// It then enters a loop and generates the specified number of bursts of specified number of characters, with a delay
// of the specified amount between each burst.
//
// The client:
// * connects to the server
// * sends the parameters for the connection to the server
// * creates a goroutine to copy the connections output to stdout and count the response bytes
// * delays for a specified number of milliseconds, then issues a CloseWrite on the connection
// * waits for the copying goroutine to finish
//
var role string
var connection ConnectionParams
var program Program
var closeDelay int
flag.StringVar(&role, "role", "client", "The role of this program - either client (default) or server")
flag.StringVar(&connection.addr, "addr", "127.0.0.1:19622", "The connection address.")
flag.Int64Var(&program.BurstSize, "burstSize", 5, "The number of bytes in each burst.")
flag.Int64Var(&program.BurstDelay, "burstDelay", 1000, "The number of milliseconds between each burst.")
flag.Int64Var(&program.InitialDelay, "initialDelay", 200, "The number of milliseconds to wait before the initial burst.")
flag.Int64Var(&program.BurstCount, "burstCount", 2, "The number of bursts to issue before closing the connection.")
flag.Int64Var(&program.PreambleSize, "preambleSize", 69, "The number of bytes of preamble to generate prior to the initial response burst.")
flag.IntVar(&closeDelay, "closeDelay", 0, "The number of milliseconds delay before shutting down the write side of the client's socket.")
flag.Parse()
var exit int
if role == "server" {
//
exit = server(connection)
} else {
exit = client(connection, program, closeDelay)
}
os.Exit(exit)
}
示例15: init
func init() {
flag.StringVar(&config_url, "url", "", "url to fetch (like https://www.mydomain.com/content/)")
flag.StringVar(&config_cert, "cert", "", "x509 certificate file to use")
flag.StringVar(&config_key, "key", "", "RSA key file to use")
flag.Int64Var(&config_requests, "requests", 10, "Number of requests to perform")
flag.Int64Var(&config_workers, "workers", 5, "Number of workers to use")
flag.IntVar(&config_cpus, "cpus", runtime.NumCPU(), "Number of CPUs to use (defaults to all)")
flag.BoolVar(&config_head_method, "head", false, "Whether to use HTTP HEAD (default is GET)")
flag.BoolVar(&config_fail_quit, "fail", false, "Whether to exit on a non-OK response")
flag.BoolVar(&config_quiet, "quiet", false, "do not print all responses")
}