Created
January 11, 2020 03:54
-
-
Save monkrus/a32d0becfb9c4a9c195688d29ce13857 to your computer and use it in GitHub Desktop.
Steps to set HTTP services in Go
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" | |
| "net/http" | |
| ) | |
| func main() { | |
| //step 2 | |
| http.HandleFunc("/", foo) | |
| //step 1 | |
| http.ListenAndServe(":8080", nil) | |
| } | |
| //step 3 | |
| func foo(w http.ResponseWriter, r *http.Request) { | |
| fmt.Fprint(w, "Hello from foo") | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment