Skip to content

Commit b8561e2

Browse files
author
Edward Muller
committed
Getting Started App
0 parents  commit b8561e2

File tree

6 files changed

+75
-0
lines changed

6 files changed

+75
-0
lines changed

Godeps/Godeps.json

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Godeps/Readme

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Godeps/_workspace/.gitignore

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Procfile

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
web: go-getting-started

README.md

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# go-getting-started
2+
3+
A barebones Go app, which can easily be deployed to Heroku.
4+
5+
This application supports the [Getting Started with Go on Heroku](https://devcenter.heroku.com/articles/getting-started-with-go) article - check it out.
6+
7+
## Running Locally
8+
9+
Make sure you have [Go](http://golang.org/doc/install) and the [Heroku Toolbelt](https://toolbelt.heroku.com/) installed.
10+
11+
```sh
12+
$ go get -u github.com/heroku/go-getting-started/...
13+
$ cd $GOPATH/src/github.com/heroku/go-getting-started
14+
$ foreman start web
15+
```
16+
17+
Your app should now be running on [localhost:5000](http://localhost:5000/).
18+
19+
You should also install [Godep](https://github.com/tools/godep) if you are going to add any dependencies to the sample app.
20+
21+
## Deploying to Heroku
22+
23+
```sh
24+
$ heroku create
25+
$ git push heroku master
26+
$ heroku open
27+
```
28+
29+
## Documentation
30+
31+
For more information about using Go on Heroku, see these Dev Center articles:
32+
33+
- [Go on Heroku](https://devcenter.heroku.com/categories/go)
34+

cmd/go-getting-started/main.go

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package main
2+
3+
import (
4+
"log"
5+
"net/http"
6+
"os"
7+
)
8+
9+
func hello(w http.ResponseWriter, r *http.Request) {
10+
w.Write([]byte("Hello From Go!"))
11+
}
12+
13+
func main() {
14+
port := os.Getenv("PORT")
15+
16+
if port == "" {
17+
log.Fatal("$PORT must be set")
18+
}
19+
20+
http.HandleFunc("/", hello)
21+
22+
if err := http.ListenAndServe(":"+port, nil); err != nil {
23+
log.Fatal(err)
24+
}
25+
}

0 commit comments

Comments
 (0)