Skip to content

Instantly share code, notes, and snippets.

@ctberthiaume
Created November 17, 2017 00:13
Show Gist options
  • Save ctberthiaume/fcf63246b0a8d6ec285a8f6781dc7fcb to your computer and use it in GitHub Desktop.
Save ctberthiaume/fcf63246b0a8d6ec285a8f6781dc7fcb to your computer and use it in GitHub Desktop.
Go hello world web server
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