[Go] HerokuにRevelでつくったアプリをデプロイする

まず、revelでアプリを作っておく。

```bash
$ revel new myapp
```

次にmyappをgitの管理下に置く。

```bash
$ cd $GOPATH/src/myapp
$ git init
$ git add .
$ git commit -m "Initial commit"
```

その次に.godirを用意する。

```bash
$ echo myapp > .godir
$ git add .
$ git commit -m "Add .godir"
```

[注意] .godirがないとgit pushした時に怒られる。

```bash
$ git push heroku master
...
remote: -----> Revel app detected
remote:  !     A .godir is required. For instructions:
remote:  !     http://mmcgrana.github.io/2012/09/getting-started-with-go-on-heroku
remote: 
remote:  !     Push rejected, failed to compile Revel app
```

.godir用意したら下記のコマンドを実行してherokuのインスタンスを作成する。

```bash
$ heroku create -b https://github.com/revel/heroku-buildpack-go-revel.git
```
Git remote heroku addedとなればOK.

```
...
Creating gentle-savannah-5631... done, stack is cedar-14
Buildpack set. Next release on gentle-savannah-5631 will use https://github.com/revel/heroku-buildpack-go-revel.git.
https://gentle-savannah-5631.herokuapp.com/ | https://git.heroku.com/gentle-savannah-5631.git
Git remote heroku added
```

[注意] robfig/heroku-buildpack-go-revelではなくrevel/heroku-buildpack-go-revelを使うこと。robfigだとgit pushした後のbuildでコケる。下記のようなログで。

```bash
remote: Compressing source files... done.
remote: Building source:
remote: 
remote: -----> Fetching custom buildpack https://github.com/robfig/heroku-buildpack-go-revel.git... done
remote: -----> Revel app detected
remote: -----> Installing Go 1.1.2... done
remote:        Installing Virtualenv...
remote:  !     Push rejected, failed to compile Revel app
remote: 
remote: Verifying deploy...
remote: 
remote: !	Push rejected to damp-peak-3771.
remote: 
To https://git.heroku.com/damp-peak-3771.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/damp-peak-3771.git'
```

念のためgit remote -vで追加されていることを確認。

```bash
$ git remote -v
heroku	https://git.heroku.com/gentle-savannah-5631.git (fetch)
heroku	https://git.heroku.com/gentle-savannah-5631.git (push)
```

最後にherokuにpushする。

```bash
$  git push heroku master
Counting objects: 41, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (34/34), done.
Writing objects: 100% (41/41), 82.73 KiB | 0 bytes/s, done.
Total 41 (delta 2), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote: 
remote: -----> Fetching custom buildpack https://github.com/revel/heroku-buildpack-go-revel.git... done
remote: -----> Revel app detected
remote: -----> Installing go1.3... done
remote:        Installing Virtualenv... done
remote:        Installing Mercurial... done
remote:        Installing Bazaar... done
remote: -----> Running: go get -tags heroku ./...
remote: 
remote: -----> Discovering process types
remote:        Procfile declares types     -> (none)
remote:        Default types for Multipack -> web
remote: 
remote: -----> Compressing... done, 60.6MB
remote: -----> Launching... done, v4
remote:        https://gentle-savannah-5631.herokuapp.com/ deployed to Heroku
remote: 
remote: Verifying deploy... done.
To https://git.heroku.com/gentle-savannah-5631.git
 * [new branch]      master -> master
```

ブラウザで確認してみる。

```
heroku open
```

It works!!

![Screen Shot 2015-11-03 at 20.17.17.png](https://qiita-image-store.s3.amazonaws.com/0/9059/c10ae868-6c37-ae85-0ed0-97247feac39c.png)

### 参考記事
- [HerokuでGo言語のRevelを動かしたい【heroku】【revel】【golang】 - DRYな備忘録](http://otiai10.hatenablog.com/entry/2014/07/10/002312#f-d0fd3a43)
- [GO用の全部のせフレームワークRevelでWEBアプリをつくる - Bye Bye Moore](http://shuzo-kino.hateblo.jp/entry/2014/09/13/234553)