Go言語のWebフレームワーク「Revel」でゲストブックアプリケーションを作ってみた
The Revel Web Framework for Go
インストール
$ go get github.com/robfig/revel/revel
コマンドラインツール
$ revel
~
~ revel! http://robfig.github.com/revel
~
usage: revel command [arguments]
The commands are:
new create a skeleton Revel application
run run a Revel application
build build a Revel application (e.g. for deployment)
package package a Revel application (e.g. for deployment)
clean clean a Revel application's temp files
test run all tests from the command-line
Use "revel help [command]" for more information.
プロジェクト作成
$ revel new revel-guestbook ~ ~ revel! http://robfig.github.com/revel ~ Your application is ready: /path/to/gopath/src/revel-guestbook You can run it with: revel run revel-guestbook
$ tree
.
├── app
│ ├── controllers
│ │ └── app.go
│ ├── init.go
│ ├── routes
│ │ └── routes.go
│ ├── tmp
│ │ └── main.go
│ └── views
│ ├── App
│ │ └── Index.html
│ ├── debug.html
│ ├── errors
│ │ ├── 404.html
│ │ └── 500.html
│ ├── flash.html
│ ├── footer.html
│ └── header.html
├── conf
│ ├── app.conf
│ └── routes
├── messages
│ └── sample.en
├── public
│ ├── css
│ │ └── bootstrap.css
│ ├── img
│ │ ├── favicon.png
│ │ ├── glyphicons-halflings-white.png
│ │ └── glyphicons-halflings.png
│ └── js
│ └── jquery-1.9.1.min.js
└── tests
└── apptest.go
とりあえず動かす
$ revel run revel-guestbook ~ ~ revel! http://robfig.github.com/revel ~ INFO 2014/01/05 12:03:29 revel.go:292: Loaded module testrunner INFO 2014/01/05 12:03:29 revel.go:292: Loaded module static INFO 2014/01/05 12:03:29 run.go:57: Running revel-guestbook (revel-guestbook) in dev mode INFO 2014/01/05 12:03:29 harness.go:157: Listening on :9000
雑感
martiniに比べるとかなり大きなフレームワーク。
ORマッパーは用意されていないのでgorpを使った。
ドキュメントは充実してるけど、martiniと比べると仕様が複雑でとっつきづらい印象。
「Hot Code Reload」なのは開発する上でとてもよい。
テンプレート関数がエラーがになったときの表示がわかりやすいのもよい。
この2点はmartiniと比べるとかなり良い点だと思った。
herokuにアップするためのbuildpackはrevel用のものが必要だった。


