Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Trivial Expvar Sample Code
package main
import (
var (
counter *ratecounter.RateCounter
hitsperminute = expvar.NewInt("hits_per_minute")
func increment(w http.ResponseWriter, r *http.Request) {
io.WriteString(w, strconv.FormatInt(counter.Rate(), 10))
func main() {
counter = ratecounter.NewRateCounter(1 * time.Minute)
http.HandleFunc("/increment", increment)
http.ListenAndServe(":8000", nil)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment