LoginSignup
4
3

More than 5 years have passed since last update.

GoのフレームワークRevelを使ってみる(インストール編)

Posted at

はじめに

Goで何かアプリを作ってみたかったのでRevelというフレームワークを使ってみました。

サーバーを立ち上げるところまでやってみます。

前提

  • macOS Sierra
  • Goがインストール済み

手順

Revelのインストール

公式ドキュメント通りでできました。
https://revel.github.io/tutorial/gettingstarted.html

Revelのインストール

$ go get github.com/revel/revel

コマンドラインツールをインストール

$ go get github.com/revel/cmd/revel

revelコマンドが使えるか確認

$ revel help

もしパスが通っていなければ下記を参考にやってみてください。

GOPATHを確認

$ go env GOPATH

僕の環境ではここでした

/Users/m1ul24/go

パスを通します
※僕はZshを使っているので.zshrcに記載しています。
Bashをお使いの方は.bash_profileか.bashrcに記述します。

~/.zshrc
# Go
export GOPATH=$HOME/go
export PATH="$PATH:$GOPATH/bin"

設定を反映

$ source ~/.zshrc

revelコマンドが使えるか確認

$ revel help

アプリケーションの作成

$ cd $GOPATH
$ revel new myapp

ブラウザからアクセスしてみます
http://localhost:9000

localhost_9000_(Laptop with HiDPI screen).png

おー!なんかダサいけど表示された!

ディレクトリ構成はこんな感じでした。

$ tree src/myapp
src/myapp
├── README.md
├── 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-3.3.6.min.css
│   ├── fonts
│   │   ├── glyphicons-halflings-regular.ttf
│   │   ├── glyphicons-halflings-regular.woff
│   │   └── glyphicons-halflings-regular.woff2
│   ├── img
│   │   └── favicon.png
│   └── js
│       ├── bootstrap-3.3.6.min.js
│       └── jquery-2.2.4.min.js
└── tests
    └── apptest.go

インストールまではとても簡単にできました。
次は実際にアプリの作成をしてみたいと思います。

4
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
3