Skip to content

Instantly share code, notes, and snippets.

@GimmyHchs
Last active January 11, 2020 04:24
Show Gist options
  • Save GimmyHchs/e5c925e1163de940aa1f09b8f70a6e6b to your computer and use it in GitHub Desktop.
Save GimmyHchs/e5c925e1163de940aa1f09b8f70a6e6b to your computer and use it in GitHub Desktop.
Reinstall go spacemacs

Reinstall go & spacemacs

Table of Contents

Remove go

  1. clean up go-build cache
$ go clean
  1. remove binary go tools
$ rm -rf $GOPATH/bin
  1. remove official src
$ rm -rf $GOPATH/src/golang.org
  1. (optional) remove source code folder.
$ cd $GOPATH/src/github.com/
$ ls
$ rm -rf folder-that-you-want-to-delete
  1. IF YOU use homebrew to install go or any go tools
$ brew list
$ brew uninstall some-go-tools
$ brew uninstall go
$ brew cleanup

IF YOU install go by dmg installer. checking uninstall doc at Go Official Uninstall doc

Remove spacemacs

  1. remove env file
$ rm -rf ~/.spacemacs.d/.spacemacs.env
$ rm -rf ~/.spacemacs.env
  1. (optional) remove .spacemacs configuration file
$ rm ~/.spacemacs
  1. remove spacemacs
$ rm -rf ~/.emacs.d
  1. remove emacs
$ brew cask uninstall emacs
$ brew uninstall emacs
$ brew cleanup

Install go

  1. install go by homebrew
$ brew install go
  1. setup GOROOT & GOPATH into $PATH

you can change GOPATH if you want.
⚠️ check more info at Officail GOPATH Doc

export GOROOT=/usr/local/opt/go/libexec
export GOPATH=$HOME/go
export PATH=$PATH:$GOPATH/bin
export PATH=$PATH:$GOROOT/bin
  1. check go env
$ go env
  1. (optional) install go tools which will use by spacemacs.
GO111MODULE=on go get -v golang.org/x/tools/gopls@latest
GO111MODULE=on CGO_ENABLED=0 go get -v -trimpath -ldflags '-s -w' github.com/golangci/golangci-lint/cmd/golangci-lint
go get -u -v golang.org/x/tools/cmd/godoc
go get -u -v golang.org/x/tools/cmd/goimports
go get -u -v golang.org/x/tools/cmd/gorename
go get -u -v golang.org/x/tools/cmd/guru
go get -u -v github.com/cweill/gotests/...
go get -u -v github.com/davidrjenni/reftools/cmd/fillstruct
go get -u -v github.com/fatih/gomodifytags
go get -u -v github.com/godoctor/godoctor
go get -u -v github.com/haya14busa/gopkgs/cmd/gopkgs
go get -u -v github.com/josharian/impl
go get -u -v github.com/mdempsky/gocode
go get -u -v github.com/rogpeppe/godef
go get -u -v github.com/zmb3/gogetdoc

go get -u -v github.com/alecthomas/gometalinter
gometalinter --install --update
  1. (optional) install for go LSP
git clone https://github.com/saibing/bingo.git $GOPATH/src/github.com/saibing/bingo
cd $GOPATH/src/github.com/saibing/bingo
git checkout 5963059ef41a42c6a7e88f3f5266f32182fbbb35
GO111MODULE=on go install

or

go get -u github.com/sourcegraph/go-langserver
  1. (optional) install vendor manually for autocomplete support . check go-layer's autocomplete
$ gocode set autobuild true
$ go install ./vendor/...
  1. (optional workaround) if guru is broken in spacemacs (SPC m f d).
ln -s $GOPATH/bin/guru /usr/local/bin/guru

Install spacemacs

  1. install emacs by homebrew
$ brew cask install emacs
  1. install spacemacs by cloning repository.
$ git clone https://github.com/syl20bnr/spacemacs ~/.emacs.d

OR

$ git clone -b develop https://github.com/syl20bnr/spacemacs ~/.emacs.d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment