GOの開発環境を構成する
2019-02-23
セットアップする端末
k636174@rabbit2018.local(19-02-23 11:07:57) ttys008 /Users/k636174
% sw_vers
ProductName: Mac OS X
ProductVersion: 10.14.3
BuildVersion: 18D109
k636174@rabbit2018.local(19-02-23 11:08:48) ttys008 /Users/k636174
%
インストール
k636174@rabbit2018.local(19-02-23 11:10:22) ttys008 /Users/k636174
% brew install goenv
----8<---SNIPE---8<-----
インストール確認
k636174@rabbit2018.local(19-02-23 11:11:37) ttys008 /Users/k636174
% zsh
k636174@rabbit2018.local(19-02-23 11:13:42) ttys008 /Users/k636174
% goenv
goenv 1.23.3
Usage: goenv <command> [<args>]
Some useful goenv commands are:
commands List all available commands of goenv
local Set or show the local application-specific Go version
global Set or show the global Go version
shell Set or show the shell-specific Go version
install Install a Go version using go-build
uninstall Uninstall a specific Go version
rehash Rehash goenv shims (run this after installing executables)
version Show the current Go version and its origin
versions List all Go versions available to goenv
which Display the full path to an executable
whence List all Go versions that contain the given executable
See `goenv help <command>' for information on a specific command.
For full documentation, see: https://github.com/syndbg/goenv#readme
k636174@rabbit2018.local(19-02-23 11:13:45) ttys008 /Users/k636174
%
シェルの変数設定
(今回はzshrcに記載)
k636174@rabbit2018.local(19-02-23 11:45:25) ttys009 /Users/k636174/Desktop/Projects/dotfiles/zsh
% diff zshrc0 .zshrc
9a10,14
>
> # Go
> export GOENV_ROOT=$HOME/.goenv
> export PATH=$GOENV_ROOT/bin:$PATH
> eval "$(goenv init -)"
k636174@rabbit2018.local(19-02-23 11:45:59) ttys009 /Users/k636174/Desktop/Projects/dotfiles/zsh
%
Goをインストール
k636174@rabbit2018.local(19-02-23 11:25:50) ttys009 /Users/k636174/Desktop/Projects/dotfiles/zsh
% goenv install -l
Available versions:
----8<---SNIPE−−−-8<----
k636174@rabbit2018.local(19-02-23 11:25:55) ttys009 /Users/k636174/Desktop/Projects/dotfiles/zsh
% goenv install 1.11.4
----8<---SNIPE−−−-8<----
k636174@rabbit2018.local(19-02-23 11:28:46) ttys009 /Users/k636174/Desktop/Projects/dotfiles/zsh
% goenv version
system (set by /Users/k636174/.goenv/version)
k636174@rabbit2018.local(19-02-23 11:29:23) ttys009 /Users/k636174/Desktop/Projects/dotfiles/zsh
% goenv global 1.11.4
k636174@rabbit2018.local(19-02-23 11:32:22) ttys009 /Users/k636174/Desktop/Projects/dotfiles/zsh
% goenv rehash
k636174@rabbit2018.local(19-02-23 11:32:31) ttys009 /Users/k636174/Desktop/Projects/dotfiles/zsh
% goenv versions
* 1.11.4 (set by /Users/k636174/.goenv/version)
k636174@rabbit2018.local(19-02-23 11:32:38) ttys009 /Users/k636174/Desktop/Projects/dotfiles/zsh
%
追加のパス設定
% diff zshrc0 .zshrc
14a15,17
>
> export GOPATH=$HOME/Desktop/Projects/
> PATH=$PATH:$GOPATH/bin
k636174@rabbit2018.local(19-02-23 11:44:25) ttys009 /Users/k636174/Desktop/Projects/dotfiles/zsh
%