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
+8.9k Golang : GMail API create and send draft with simple upload attachment example
+5.8k Golang : List all packages and search for certain package
+27.5k Golang : Convert integer to binary, octal, hexadecimal and back to integer
+7.7k Golang : Test if an input is an Armstrong number example
+17k Golang : Get input from keyboard
+7k Golang : Find the shortest line of text example
+18.5k Golang : Send email with attachment
+7.4k Golang : Example of custom handler for Gorilla's Path usage.
+8.9k Golang : What is the default port number for connecting to MySQL/MariaDB database ?
+20.9k Golang : Convert PNG transparent background image to JPG or JPEG image
+13.7k Golang : Image to ASCII art example
+29.5k Golang : Saving(serializing) and reading file with GOB