Skip to content

Instantly share code, notes, and snippets.

@dwurf
Last active September 1, 2019 02:28
Show Gist options
  • Save dwurf/25d26181b407a58ab8a67e824675e487 to your computer and use it in GitHub Desktop.
Save dwurf/25d26181b407a58ab8a67e824675e487 to your computer and use it in GitHub Desktop.
Go web server - hello world!
module https://gist.github.com/dwurf/25d26181b407a58ab8a67e824675e487
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