golang-eclipse

You want to program Golang but having a hard time working on Eclipse to get it working?

Here is a simple speedorial:

Installation Requirements:

    • Java VM version 8 or later.

    • Eclipse 4.6 (Neon) or later.

    • CDT 9.0 or later (this will be installed or updated automatically as part of the steps below).

Instructions:

    1. Use your existing Eclipse, or download a new Eclipse package from http://www.eclipse.org/downloads/.

    2. Start Eclipse, go to Help -> Install New Software...

    3. Click the Add... button, then enter the Update Site URL: http://goclipse.github.io/releases/ in the Location field, click OK.

    4. Select the recently added update site in the Work with: dropdown. Type GoClipse in the filter box. Now the Goclipse feature should appear below.

    5. Select the GoClipse feature, and complete the wizard.

        • Dependencies such as CDT will automatically be added during installation.

    6. Restart Eclipse.

    7. Follow the instructions from the User Guide's Configuration section to configure the required external tools. It is recommended you read the rest of the guide too.

1 Eclipse

    • Install golang package: sudo apt-get install golang

    • Download Eclipse

    • Start Eclipse

    • Go to Help->Install new software

    • Add Goclipse URL: http://goclipse.github.io/releases/

    • Select All Availible sites and search for goclipse, select and install.

    • Restart Eclipse when prompted.

2 Eclipse Go Settings

    • Go to Window-> Preferences

    • Select Go

    • GOROOT: /usr/lib/go

    • GOPATH: /usr/share/go

    • Go-tool path: /usr/bin/go

    • Go formatter: /usr/bin/gofmt

    • Go documentor: /usr/bin/godoc

3 GoCode for Autocompletion

    • Make sure you have git installed: sudo apt-get install git

    • Get gocode with: sudo go get -u github.com/nsf/gocode

    • In Eclipse go to Window-> Preferences

    • Select Go-> Gocode (Submenu)

    • Gocode path: /usr/lib/go/bin/gocode