norinyang メガ進化!


Golang の開発環境構築

Mac で Go のビルド環境を構築した。
brew で簡単にインストールできたので良いですね


brew update
brew install go


As of go 1.2, a valid GOPATH is required to use the `go get` command:

`go vet` and `go doc` are now part of the sub repo:

To get `go vet` and `go doc` run:
  go get
  go get

You may wish to add the GOROOT-based install location to your PATH:
  export PATH=$PATH:/opt/boxen/homebrew/opt/go/libexec/bin

最後の PATH 部分は入れる環境によって差があると思います
ぼくは昔遊んだ boxen で homebrew が入っているので変なパスが書かれている


How to Write Go Code - The Go Programming Language

The GOPATH environment variable specifies the location of your workspace. It is likely the only environment variable you'll need to set when developing Go code.

To get started, create a workspace directory and set GOPATH accordingly. Your workspace can be located wherever you like, but we'll use $HOME/go in this document. Note that this must not be the same path as your Go installation.

ドキュメント中では $Home/go をワーキングディレクトリにしているっぽい

mkdir ~/Development/Go
export GOPATH=~/Development/Go


For convenience, add the workspace's bin subdirectory to your PATH:

設定したワークスペースのサブディレクトリ bin を PATH に入れておく必要があるので下記を追加

export PATH=$PATH:$GOPATH/bin

Go 1.2 Release Notes - The Go Programming Language

Both binaries are still included with the distribution, but the source code for the godoc and vet commands has moved to the subrepository.

Also, the core of the godoc program has been split into a library, while the command itself is in a separate directory. The move allows the code to be updated easily and the separation into a library and command makes it easier to construct custom binaries for local sites and different deployment methods.

Updating: Since godoc and vet are not part of the library, no client Go code depends on the their source and no updating is required.

The binary distributions available from include these binaries, so users of these distributions are unaffected.

When building from source, users must use "go get" to install godoc and vet. (The binaries will continue to be installed in their usual locations, not $GOPATH/bin.)

なんかごちゃごちゃ書いてあるけど、godoc と vet が入ってないって話が書いてあって


go get
go get

これで先ほど指定した GOPATH いかに pkg, src が出来上がっているはず


You may wish to add the GOROOT-based install location to your PATH: