Created
June 25, 2014 11:08
-
-
Save zoncoen/4728b0011cfa5ec88ad1 to your computer and use it in GitHub Desktop.
expvar package demo for Gunosy.go #3.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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