Golang expvar.Var type and Get() function example
package expvar
Var type is an abstract type for all exported variables.
Get function retrieves a named exported variable.
Golang expvar.Var type usage example
type Graphite struct {
endpoint string
interval time.Duration
timeout time.Duration
connection net.Conn
vars map[string]expvar.Var
registrations chan namedVar
shutdown chan chan bool
}
g := &Graphite{
endpoint: endpoint,
interval: interval,
timeout: timeout,
connection: nil,
vars: map[string]expvar.Var{},
registrations: make(chan namedVar),
shutdown: make(chan chan bool),
}
Golang expvar.Get() function usage example
...
reqs := expvar.NewFloat("requests-float")
if reqs.f != 0.0 {
fmt.Printf("reqs.f = %v, want 0", reqs.f)
}
if reqs != expvar.Get("requests-float").(*Float) {
fmt.Printf("Get() failed.")
}
...
Advertisement
Something interesting
Tutorials
+6.3k Golang : Test input string for unicode example
+11.1k Golang : Simple image viewer with Go-GTK
+7k Golang : Takes a plural word and makes it singular
+5.5k Golang : Stop goroutine without channel
+8.3k Golang : Oanda bot with Telegram and RSI example
+17.5k Golang : Clone with pointer and modify value
+13k Golang : Calculate elapsed years or months since a date
+10.5k Generate Random number with math/rand in Go
+15.2k Golang : Accurate and reliable decimal calculations
+10k Golang : Convert octal value to string to deal with leading zero problem
+5.6k Fix fatal error: evacuation not done in time problem
+7.5k Golang : Process json data with Jason package