package main import ( "fmt" "log" "net" "net/http" "github.com/pkg/browser" ) func handleHome(w http.ResponseWriter, r *http.Request) { fmt.Fprint(w, "

Hello Peachy!

") } func run() error { listener, err := net.Listen("tcp", ":0") if err != nil { return err } port := listener.Addr().(*net.TCPAddr).Port homeURL := fmt.Sprintf("http://localhost:%d", port) err = browser.OpenURL(homeURL) if err != nil { fmt.Printf("I couldn't open the browser automatically.\nDo it yourself, then go to %s.", homeURL) } return http.Serve(listener, http.HandlerFunc(handleHome)) } func main() { err := run() if err != nil { log.Fatal(err) } }