Go

Go環境構築 for Mac

More than 1 year has passed since last update.

Goの環境構築の備忘録

brew install go
#GOPATH
export GOPATH=$HOME/dev
export PATH=$PATH:$GOPATH/bin
#確認
go get github.com/motemen/gore
ls $GOPATH

go get github.com/nsf/gocode
go get github.com/k0kubun/pp
go get golang.org/x/tools/cmd/godoc

#ghq
brew install ghq
git config --global ghq.root $GOPATH/src

#peco
brew install peco
vim ~/.bashrc
"""
export HISTCONTROL="ignoredups"
peco-history() {
    local NUM=$(history | wc -l)
    local FIRST=$((-1*(NUM-1)))

    if [ $FIRST -eq 0 ] ; then
        history -d $((HISTCMD-1))
        echo "No history" >&2
        return
    fi  

    local CMD=$(fc -l $FIRST | sort -k 2 -k 1nr | uniq -f 1 | sort -nr | sed -E 's/^[0-9]+[[:blank:]]+//' | peco | head -n 1)

    if [ -n "$CMD" ] ; then
        history -s $CMD

        if type osascript > /dev/null 2>&1 ; then
            (osascript -e 'tell application "System Events" to keystroke (ASCII character 30)' &)
        fi  
    else
        history -d $((HISTCMD-1))
    fi  
}
bind -x '"\C-r":peco-history'
"""

#めんどいので全部入れる
go get golang.org/x/tools/cmd/...
go get github.com/nsf/gocode
go get github.com/rogpeppe/godef
go get github.com/jstemmer/gotags