Skip to content

Instantly share code, notes, and snippets.

@mid0111
Last active February 7, 2016 07:05
Show Gist options
  • Save mid0111/14bcae45f120704d578e to your computer and use it in GitHub Desktop.
Save mid0111/14bcae45f120704d578e to your computer and use it in GitHub Desktop.
Go で開発する際のツール・フレームワーク・ライブラリ調査

Go で web サーバを記述するのによさそうなフレームワークの調査

web フレームワーク

Martini

Github
website

  • 最新バージョン(2016/02/06 時点)

    • v1.0 on 20 May 2014
  • 最初のリリース

    • Pre-release v0.1 on 5 Dec 2013
  • Github スター

    • 8,177

特徴

  • Github スター数一番人気(martini, revel, goji)
  • シンプル
  • 他のGolangパッケージとの協調性
  • パスマッチングとルーティング
  • モジュラーデザイン - 機能性の付け外しが簡単
  • たくさんの良いハンドラ/ミドルウェア
  • http.HandlerFuncとの完全な互換性
  • リリースはあまり頻繁でない。現在も開発は行われている

使い方

go get github.com/go-martini/martini
package main

import "github.com/go-martini/martini"

func main() {
  m := martini.Classic()
  m.Get("/", func() string {
    return "Hello world!"
  })
  m.Run()
}
go run server.go

License

MIT

revel

Github
website

  • 最新バージョン(2016/02/06 時点)

    • v0.12.0 on 26 Mar 2015
  • 最初のリリース

    • Pre-release v0.6 on 16 Sep 2013
    • v0.8 on 6 Jan 2014
  • Github スター

    • 6,336

特徴

  • フルスタック系
    • シンプルではないので Go の思想好きからの支持は低め
  • Hot Code Reload
  • routing
  • parameter parsing
  • validation
  • session/flash
  • templating
  • caching
  • jobs
    • 非同期に処理を実行するための仕組み
    • cron 実行っぽいこともできる
  • test framework
  • internationalization
  • Stateless
  • Modular
    • 例)ルータをカスタムルータに置き換える
  • 2014 年よりはリリース速度など落ちているみたいだけど、現在も開発は行われている

使い方

go get github.com/revel/revel
go get github.com/revel/cmd/revel
cd $GOPATH
revel new github.com/mid0111/hello-revel
~
~ revel! http://revel.github.io
~
Your application is ready:
   /Users/mid0111/.gvm/pkgsets/go1.5/global/src/github.com/mid0111/hello-revel

You can run it with:
   revel run github.com/mid0111/hello-revel
tree
.
├── README.md
├── app
│   ├── controllers
│   │   └── app.go
│   ├── init.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

12 directories, 19 files
# サーバ起動
revel run github.com/mid0111/hello-revel

# テスト実行用の画面表示
open http://localhost:9000/@tests

# コマンドラインからテスト実行
revel test github.com/mid0111/hello-revel/

License

MIT

Goji

Github
website

  • 最新バージョン(2016/02/06 時点)

    • v0.9.0 on 1 Feb 2015
  • 最初のリリース

    • v0.8 on 2 Nov 2014
  • Github スター

    • 2,945

特徴

  • minimalistic
  • routing
  • Middleware
  • Graceful shutdown, graceful reload
  • fully composable with net/http
    • http.Handler として使える
    • サードパーティ製ライブラリと合わせて使える
  • 2014 年よりはリリース速度など落ちているみたいだけど、現在も開発は行われている

フレームワークのデザインコンセプト

  • シンプル、必要最低限であること

    • ディレクトリのどこに何をおいたらいいかをフレームワークに強制してほしい人には向かない
  • 後述の Martini と設計思想は同じだけど、Martini と違い、黒魔術を使っていない

License

MIT

所感

  • Martini
    • revel ほどのフルスタックではないけど、Middleware とかと合わせると web フレームワークとしての機能は十分そう
    • スター数1位、v1.0、信頼できそう
  • Revel
    • 設計のためのコスト負担を減らしてくれそう
    • Revel の開発止まったら死ぬ
    • Revel ならではのルールのための勉強コストがかかる
  • Goji
    • シンプルなので自由がきくのは便利そうだけどシンプルすぎっぽい
  • 関係ないけどいいリリースノートの管理方法だな
    https://github.com/revel/revel/releases/tag/v0.12.0

パッケージマネージャー

gom

Github

特徴

  • mattn さんがつくってる
  • 環境毎に切り替えられる
  • gom lock を実行すれば Gomfile.lock が作られて、以降の gom install では依存ライブラリのバージョンを正確に反映できます

go のバージョン切り替えツール

gvm

  • github スター数そこそこ
  • メンテナンスもされている
@mid0111
Copy link
Author

mid0111 commented Feb 7, 2016

結構メジャープロジェクトで使われている。
Martini と似てるけどとにかく早いらしい。
https://github.com/gin-gonic/gin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment