Skip to content

Instantly share code, notes, and snippets.

@kesselborn
Created July 20, 2012 14:18
Show Gist options
  • Save kesselborn/3150970 to your computer and use it in GitHub Desktop.
Save kesselborn/3150970 to your computer and use it in GitHub Desktop.
Heroku go sample project
github.com/soundcloud/gotest

Create a heroku app with go-src buildpack with:

heroku create -s cedar --buildpack [email protected]:kesselborn/heroku-buildpack-go.git

package main
import (
"fmt"
"os"
"net/http"
)
func handler(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hi there, I hate %s!", r.URL.Path[1:])
}
func main() {
port := ":" + os.Getenv("PORT")
if port == ":" {
port = ":8080"
}
fmt.Println("starting web server on port ", port)
http.HandleFunc("/", handler)
http.ListenAndServe(port, nil)
}
web: ./bin/gotest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment