Skip to content

Instantly share code, notes, and snippets.

@sonyarianto
Created December 5, 2018 09:37
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 sonyarianto/92a3d645af2370762cd749b2093da7d3 to your computer and use it in GitHub Desktop.
Save sonyarianto/92a3d645af2370762cd749b2093da7d3 to your computer and use it in GitHub Desktop.
Hello World on web 2
package main
import (
"io"
"log"
"net/http"
)
func Default(w http.ResponseWriter, r *http.Request) {
if r.URL.Path != "/" {
http.NotFound(w, r)
return
}
w.Header().Set("Content-Type", "text/html; charset=utf-8")
io.WriteString(w, "<h1>hello, world</h1>")
}
func main() {
http.HandleFunc("/", Default)
log.Fatal(http.ListenAndServe(":3000", nil))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment