Skip to content

Instantly share code, notes, and snippets.

@sonyarianto
Created December 5, 2018 09:36
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/490999458905896135d16c1ddad92a7b to your computer and use it in GitHub Desktop.
Save sonyarianto/490999458905896135d16c1ddad92a7b to your computer and use it in GitHub Desktop.
Hello World on web
package main
import (
"io"
"log"
"net/http"
)
func Default(w http.ResponseWriter, r *http.Request) {
if r.URL.Path != "/" {
http.NotFound(w, r)
return
}
io.WriteString(w, "hello, world")
}
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