-
-
Save nxpatterns/52f7f133a4080f31a645e778c75f4b44 to your computer and use it in GitHub Desktop.
Revisions
-
filewalkwithme renamed this gist
Feb 8, 2015 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
filewalkwithme created this gist
Feb 8, 2015 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,28 @@ package main import ( "net/http" ) func main() { go func() { http.ListenAndServe(":8001", &fooHandler{}) }() //the last call is outside goroutine to avoid that program just exit http.ListenAndServe(":8002", &barHandler{}) } type fooHandler struct { } func (m *fooHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { w.Write([]byte("Listening on 8001: foo ")) } type barHandler struct { } func (m *barHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { w.Write([]byte("Listening on 8002: bar ")) }