LoginSignup
15
14

More than 5 years have passed since last update.

Gin Web Frameworkを試してみたよ

Posted at

GitHub

osamingo/golang-gin-example

Install Go

Goをインストールする。

$ brew update
$ brew install go --cross-compile-all

launchctlに登録する。

/etc/launchd.conf
setenv GOROOT /usr/local/Cellar/go/1.3.1/libexec
setenv GOPATH $HOME/.go
$ launchctl < /etc/launchd.conf

Run golang-gin-example

パッケージマネージャにgoopを使用しているので、インストールする。

$ go get github.com/nitrous-io/goop

対象のリポジトリをクローンする。

$ git clone git@github.com:osamingo/golang-gin-example.git

ディレクトリを移動して、依存関係を解決する。
goopコマンドが見つからない場合は、$GOPATH/bin/goopとかに存在するのでPATHを通す。

$ cd golang-gin-example
$ goop install

go runで動かす。

$ goop go run src/main.go

起動後、http://localhost:8080/pingに繋がるか確認できればOKです。

Install IntelliJ IDEA & Golang plugin

IntelliJ IDEA

DL site: IntelliJ IDEA - The Best Java and Polyglot IDE

上記のサイトから、通常通りインストールする。

Install Golang plugin

EAP DL site: @dlsniper's dropbox (@via/ go-lang-plugin-org/go-lang-idea-plugin)

最新版のプラグインを使用したいので、作者のDropboxからEAPのjarをDLする。

install-plugin-from-jar

上記のハイライトしているボタンを押下してインストールする。

Start IntelliJ IDEA

コマンドラインから起動しないと、何故かGOROOTを見てくれないので、openコマンドで起動する。

$ open /Applications/IntelliJ\ IDEA\ 13\ CE.app

起動後、Import Project...からプロジェクトをインポートする。

import-project-one

import-project-two

import-project-three

インポート後、Shift + Command + Aで、Find Actionを起動させる。

edit-configurations

.vendorGOPATHを通す。

edit-configurations-detail

main.goを右クリックし、起動させる。

run-main

起動後、http://localhost:8080/pingに繋がるか確認できればOKです。

15
14
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
15
14