Last active
September 1, 2019 02:28
-
-
Save dwurf/25d26181b407a58ab8a67e824675e487 to your computer and use it in GitHub Desktop.
Go web server - hello world!
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
module https://gist.github.com/dwurf/25d26181b407a58ab8a67e824675e487 |
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 ( | |
"fmt" | |
"net/http" | |
) | |
func main() { | |
http.HandleFunc("/", HelloServer) | |
http.ListenAndServe(":80", nil) | |
} | |
func HelloServer(w http.ResponseWriter, r *http.Request) { | |
fmt.Fprintf(w, "Hello, %s!", r.URL.Path[1:]) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment