Last active
September 23, 2017 00:58
-
-
Save mmcloughlin/35fe28c93d72f75b360dc6527d169831 to your computer and use it in GitHub Desktop.
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 characters
| package main | |
| import ( | |
| "fmt" | |
| "log" | |
| "net/http" | |
| _ "net/http/pprof" | |
| ) | |
| func main() { | |
| http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { | |
| fmt.Fprintf(w, "Hello World!") | |
| }) | |
| log.Fatal(http.ListenAndServe(":8080", nil)) | |
| } |
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 characters
| package main | |
| import ( | |
| "fmt" | |
| "log" | |
| "net/http" | |
| _ "net/http/pprof" | |
| ) | |
| func main() { | |
| // Pprof server. | |
| go func() { | |
| log.Fatal(http.ListenAndServe("localhost:8081", nil)) | |
| }() | |
| // Application server. | |
| mux := http.NewServeMux() | |
| mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { | |
| fmt.Fprintf(w, "Hello World!") | |
| }) | |
| log.Fatal(http.ListenAndServe(":8080", mux)) | |
| } |
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 characters
| package main | |
| import ( | |
| "fmt" | |
| "log" | |
| "net/http" | |
| _ "net/http/pprof" | |
| ) | |
| func main() { | |
| // Save pprof handlers first. | |
| pprofMux := http.DefaultServeMux | |
| http.DefaultServeMux = http.NewServeMux() | |
| // Pprof server. | |
| go func() { | |
| log.Fatal(http.ListenAndServe("localhost:8081", pprofMux)) | |
| }() | |
| // Application server. | |
| http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { | |
| fmt.Fprintf(w, "Hello World!") | |
| }) | |
| log.Fatal(http.ListenAndServe(":8080", nil)) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment