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

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

示例1: New

func New(inst string) {
    instance = inst

    exp.Exp(metrics.DefaultRegistry)

    expvar.NewString("instance").Set(instance)
    expvar.NewString("service").Set(service)
}

开发者ID:graphite-ng,项目名称:carbon-relay-ng,代码行数:8,代码来源:metrics_wrapper.go

示例2: init

func init() {
    expvar.NewString("goVersion").Set(runtime.Version())
    expvar.NewString("iconVersion").Set(besticon.VersionString)

    expvar.NewString("timeLastDeploy").Set(parseUnixTimeStamp(os.Getenv("DEPLOYED_AT")).String())
    expvar.NewString("timeStartup").Set(time.Now().String())
    expvar.Publish("timeCurrent", expvar.Func(func() interface{} { return time.Now() }))
}

开发者ID:undernewmanagement,项目名称:besticon,代码行数:8,代码来源:expvar.go

示例3: main

func main() {

    port := flag.Int("p", 8080, "port to listen on")
    input := flag.String("f", "", "file with signatures to load")
    useVPTree := flag.Bool("vptree", true, "load vptree")
    useStore := flag.Bool("store", true, "load simstore")
    storeSize := flag.Int("size", 6, "simstore size (3/6)")
    cpus := flag.Int("cpus", runtime.NumCPU(), "value of GOMAXPROCS")
    myNumber := flag.Int("no", 0, "id of this machine")
    totalMachines := flag.Int("of", 1, "number of machines to distribute the table among")
    small := flag.Bool("small", false, "use small memory for size 3")

    flag.Parse()

    expvar.NewString("BuildVersion").Set(BuildVersion)

    log.Println("starting simd", BuildVersion)

    log.Println("setting GOMAXPROCS=", *cpus)
    runtime.GOMAXPROCS(*cpus)

    if *input == "" {
        log.Fatalln("no import hash list provided (-f)")
    }

    err := loadConfig(*input, *useStore, *storeSize, *small, *useVPTree, *myNumber, *totalMachines)
    if err != nil {
        log.Fatalln("unable to load config:", err)
    }

    if *useStore {
        http.HandleFunc("/search", func(w http.ResponseWriter, r *http.Request) { searchHandler(w, r) })
    }

    if *useVPTree {
        http.HandleFunc("/topk", func(w http.ResponseWriter, r *http.Request) { topkHandler(w, r) })
    }

    go func() {
        sigs := make(chan os.Signal)
        signal.Notify(sigs, syscall.SIGHUP)

        for {
            select {
            case <-sigs:
                log.Println("caught SIGHUP, reloading")

                err := loadConfig(*input, *useStore, *storeSize, *small, *useVPTree, *myNumber, *totalMachines)
                if err != nil {
                    log.Println("reload failed: ignoring:", err)
                    break
                }
            }
        }

    }()

    log.Println("listening on port", *port)
    log.Fatal(http.ListenAndServe(":"+strconv.Itoa(*port), nil))
}

开发者ID:xukai504087493,项目名称:go-simstore,代码行数:60,代码来源:main.go

示例4: main

func main() {
    flag.Parse()
    expvar.NewString("listen_port").Set(*listenPort)

    stdout := log.New(os.Stdout, "", log.Ldate|log.Ltime)
    stderr := log.New(os.Stderr, "", log.Ldate|log.Ltime)

    http.Handle("/msg", idHandler(stdout, stderr))

    logMessage(stdout,
        &Message{
            Source: &PROG,
            Key:    &STATUS,
            Content: map[string]interface{}{
                "status": "listening",
                "port":   *listenPort,
            },
        })

    err := http.ListenAndServe(fmt.Sprintf(":%s", *listenPort), nil)
    if err != nil {
        logMessage(stderr,
            &Message{
                Source: &PROG,
                Key:    &ERR,
                Content: map[string]interface{}{
                    "error": fmt.Sprintf("error starting to listen: %s", err),
                },
            })
        os.Exit(1)
    }
}

开发者ID:JoelPM,项目名称:httpjsonlogger,代码行数:32,代码来源:httpjsonlogger.go

示例5: init

func init() {
    expvar.NewString("service.startTime").Set(time.Now().String())

    // Suppress usage output. Any errors will be complained about when the user
    // parses flags anyway.
    fs.Usage = func() {}
    fs.SetOutput(nullWriter{})
}

开发者ID:postfix,项目名称:service,代码行数:8,代码来源:service.go

最后编辑: kuteng  文档更新时间: 2021-08-23 19:14   作者:kuteng