$ wget https://storage.googleapis.com/golang/go1.7.3.linux-amd64.tar.gz
$ tar -C ~/.go zxvf go1.7.3.linux-amd64.tar.gz
$ vim ~/.bashrc
+ export GOROOT="$HOME/.go/go"
+ export GOPATH="$HOME/.go/extend"
+ export PATH="$GOROOT/bin:$GOPATH/bin:$PATH"
$ source ~/.bashrc
$GOROOT
はGo本体の配置場所
$GOPATH
はサードパーティ製のパッケージを配置する場所
go get
した時のソースやgo install
した時のバイナリが置かれる場所
Go本体はバージョンアップで古いGoを消すはずなので、
$GOPATH
と$GOROOT
は分けた方が良い気がしてる
$ go get github.com/revel/revel
$ go get github.com/revel/cmd/revel
$ revel help
~
~ revel! http://revel.github.io
~
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
version displays the Revel Framework and Go version
Use "revel help [command]" for more information.
$ mkdir -p $GOPATH/src/github.com/user
$ revel new github.com/user/appname
~
~ revel! http://revel.github.io
~
Your application is ready:
/home/user/.go/extend/src/github.com/user/appname
You can run it with:
revel run github.com/user/appname
$ revel run github.com/user/appname
~
~ revel! http://revel.github.io
~
INFO 2016/11/08 13:19:56 revel.go:365: Loaded module static
INFO 2016/11/08 13:19:56 revel.go:365: Loaded module testrunner
INFO 2016/11/08 13:19:56 revel.go:230: Initialized Revel v0.13.1 (2016-06-06) for >= go1.4
INFO 2016/11/08 13:19:56 run.go:57: Running appname (github.com/user/appname) in dev mode
INFO 2016/11/08 13:19:56 harness.go:170: Listening on :9000
$ revel build github.com/user/appname appname
$ cd appname
$ ./run.sh
//RubyのPassenger的なのは不要
//nginxで80->9000にマップしてscreenで走らせておくと良いかも
Running application in development mode.
$ revel run github.com/user/appname
Running test.
$ revel test github.com/user/appname
Build and run the application.
$ revel build github.com/user/appname deploypath
$ cd deploypath
$ ./run.sh
$ vim app/controller/menu.go
+ package controllers
+ import "github.com/revel/revel"
+ type Menu struct {
+ *revel.Controller
+ }
+ func (c Menu) Index() revel.Result {
+ return c.Render()
+ }
$ vim conf/routes
+ GET /menu Menu.Index
$ vim app/views/Menu/Index.html
+ <h1>Hello Revel!</h1>