Skip to content

Instantly share code, notes, and snippets.

@sighmin
Created April 14, 2015 05:53
Show Gist options
  • Select an option

  • Save sighmin/37a76bc27471dcdeffce to your computer and use it in GitHub Desktop.

Select an option

Save sighmin/37a76bc27471dcdeffce to your computer and use it in GitHub Desktop.
Go hello world http server
package main
import (
"fmt"
"log"
"net/http"
)
type Hello struct{}
func (h Hello) ServeHTTP(w http.ResponseWriter, r *http.Request) {
fmt.Fprint(w, "Hello world!")
}
func main() {
var h Hello
err := http.ListenAndServe("localhost:4000", h)
if err != nil {
log.Fatal(err)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment