Table of Contents

Installation

apt-get install golang-go gocode golang-golang-x-tools golint

manual update to latest versuion

sudo go get -u github.com/nsf/gocode
sudo go get -u github.com/rogpeppe/godef
sudo go get -u golang.org/x/tools/cmd/guru

GOPATH

Single GOPATH:

You can have multiple projects in a single GOPATH. Each project will have a main.go in a different package. 
Often this is the right way to go. All the projects will share the same dependencies, when you 
upgrade a library each project will be updated. This works well when all the projects are updated and 
deployed together (like micro services).

GOPATH directory structure:

example

Example setup of GOPATH:

Edit ~/.bashrc to add the following line:

~/.bashrc
export GOPATH=$HOME/go

re-login to apply changes.

use setpath tool

setpath Download: https://s3.ap-south-1.amazonaws.com/gosetpath/setpath_linux_64

cd ~/project/src
setpath go get github.com/golang/example/hello

setpath will automatically set GOPATH to correct path, even if executed deeply inside ~/project subdirs.

dependencies

To download dep command:

setpath go get -u github.com/golang/dep/cmd/dep

dep reads two files called Gopkg.toml and the Gopkg.lock

Commands:

  init     Set up a new Go project, or migrate an existing one
  status   Report the status of the project's dependencies
  ensure   Ensure a dependency is safely vendored in the project
  version  Show the dep version information
  check    Check if imports, Gopkg.toml, and Gopkg.lock are in sync
cd ~/project/src/github.com/muka/go-bluetooth
setpath ${GOPATH}/bin/dep ensure

and new packages will be downloaded to ~/project/src/github.com/muka/go-bluetooth/vendor

More here: https://medium.freecodecamp.org/an-intro-to-dep-how-to-manage-your-golang-project-dependencies-7b07d84e7ba5

Eclipse IDE

GoClipse plugin for Eclipse. Installation: GoClipse installation

go get github.com/rogpeppe/godef
go get golang.org/x/tools/cmd/guru

Configure GO plugin:

GOROOT is not defined

Issues

panic: Can't find the package clause

Probably gocode version mismatch: