Skip to content

Instantly share code, notes, and snippets.

@zoncoen
Created June 25, 2014 11:08
Show Gist options
  • Save zoncoen/4728b0011cfa5ec88ad1 to your computer and use it in GitHub Desktop.
Save zoncoen/4728b0011cfa5ec88ad1 to your computer and use it in GitHub Desktop.
expvar package demo for Gunosy.go #3.
package main
import (
"expvar"
"io"
"net/http"
)
var numCalls = expvar.NewInt("num_calls")
func helloHandler(w http.ResponseWriter, req *http.Request) {
numCalls.Add(1)
io.WriteString(w, "Hello Gopher!\n")
}
func main() {
http.HandleFunc("/", helloHandler)
http.ListenAndServe(":8080", nil)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment