Skip to content

Instantly share code, notes, and snippets.

@dwurf
Last active September 1, 2019 02:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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