Created
November 17, 2017 00:13
-
-
Save ctberthiaume/fcf63246b0a8d6ec285a8f6781dc7fcb to your computer and use it in GitHub Desktop.
Go hello world web server
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 ( | |
"io" | |
"log" | |
"net/http" | |
) | |
// hello world, the web server | |
func HelloServer(w http.ResponseWriter, req *http.Request) { | |
log.Print("Received request") | |
io.WriteString(w, "hello, world!\n") | |
} | |
func main() { | |
http.HandleFunc("/hello", HelloServer) | |
log.Fatal(http.ListenAndServe(":12345", nil)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment