Installing Golang IDE Support in Intellij

Installing Golang IDE Support in Intellij

Docker Gopher Banner

Installing Golang IDE Support in Intellij

I have always preferred Intellij Community Edition IDE for Java, Bash, Python, Node and anything else I have needed, including recently C/C++ which is pretty slick. The plus is I can hang on to key-mappings, syntax color and general workflow all in a ubiquitous dev environment. There are some good IDE options for Go and of course support for the staunch EMACS/VIM purist. I like the background support an IDE offers but to each their own. There is a nice community driven project for an Intellij Golang plugin hosted on github. It is a Java project that is very active. At any time you can go to Intellij Prefrences -> Plugins -> search for ‘golang’.

Golang IDE Intellij Plugin Nightly Build
Update go-lang-idea-plugin 1.0.0.alpha
Update: you the plugin is now integrated into the Jetbrains plugin CI for nightly builds. If you are only interested in getting the latest nightly or versioned release you can add the Jetbrains “Custom Plugin Repository” under Settings -> Plugins -> Browse Repositories -> Manage Repositories. Once added, if you chose the nightly build you will get a notification when the nightly build runs that you have an update to the Go plugin. I didn’t try and force the update right away because I had already had the latest build running in a cronjob locally, but you will start seeing update notifications within 24 hours of adding the repo.

More from the Github repo: IDEA Golang Pre-Release Builds

The rest of the post is still valid for hacking and compiling the plugin with your modifications or is you just want to build it yourself.

The two build repos are:

  • alpha releases: https://plugins.jetbrains.com/plugins/alpha/list
  • nightly: https://plugins.jetbrains.com/plugins/nightly/list

Here is a screen cap of the custom repo add/edit:



The rest of the post is how to install the latest Alpha branch from trunk to build or for development work on the project itself. The alpha has some fantastic improvements from the older packaged in Inellij 3rd party plugins release from last year. We will clone the plugin source code, switch to the v1.0.0-alpha0 branch and build the plugin using the IDEA Java SDK. It is quite simple and quick once you have the right steps nailed down. Lastly, this is all being done on a Mac, I am guessing the process is similar if not the same but no guarantees or nerd rage if it doesn’t 🙂

Clone Golang Plugin Using Git

This can be done using the Git plugin inside of the Intellij IDE but its just faster and easier to show using the CLI. It can be downloaded anywhere since this is Java and not Go so the static linking locations of Go are irrelevant.

Here is a more verbose output for those newish to git.

Build and Install the Golang Plugin In Intellij

Now open up Intellij and go to File -> Open and browse to the directory you cloned the Golang plugin into.

This will open the project in Intellij, but you will now need to specify the proper Intellij Plugin Dev SDK. Select ‘Project Structure…’ from the menu.

Next click on ‘Project’ if it is showing [invalid] since an SDK needs to be specified.

In the drop down menu, choose IDEA IC-xxx SDK as shown below. It is recommended to use Java 1.6, not to mention Java on a Mac is crap shoot. Now that I rarely dev in Java anymore I just use the Apple Java lib to try and avoid JDK pain. Anyways, below is what works for me, more on it in the link above 🙂 Note: The host I took the screenshot from still had Go v1.3.3 on it. The Alpha plugin supports Go v1.4.1 and supported it within a week or two of release.

Now we are all set to build the plugin with Build -> Build Artifacts

In the popup, choose -> go.zip -> build

This generates a zip file named go.zip located in the go-lang-idea-plugin/bin/ directory.

Finally its time to install the Go plugin itself in the ‘Preferences’ settings.

Click ‘install plugin from disk’ find the newly built go.zip, reboot and you can start hacking in Intellij and Go using the latest features from the go-lang-idea-plugin project!

Just to reiterate, this is only if you want the latest 9 months of feature work or are looking to get started contributing to the project itself. There is a pre-v1.0 release in the Intellij plugin directory. The Intellij IDEA community edition is free and has all the features I need since Im mostly all Go these days but when I use full time Java the added features were super handy and much more sane then the other loosely coupled OSS IDE free for all projects. Not too commercial but they also have free license grants to open source projects, students and half off for startups. I like it, they earned plugs from me.

The plugin project maintainers seem very friendly and responsive. They use Gitter on their Github page which I <3 for working with the community and raised issues. So if you use it, help with bugs/issues even if just bringing one up or eventually sending in pull requests with bug fixes. If you are new to Go, check out some resources and simple intro snippets in this post: Golang for Network Ops →. I will be trying to get one out at least every other week. I think the flexibility Go presents for a “get shit done” natively tooled, good for both the Python programmer or the C programmer that intersect nice for Devops. In a world of ever growing density, Go is highly performant that compiles down to native machine code that can be delivered in a binary and makes it a great fit for scaling distributed systems.


Thats all for now, Im sure there are lots of ways to do this, I will update as I get feedback if there is a more preferred method to build the plugin but this is quick and simple for a weekly refresh for me. Thanks for stopping by!

About the Author

Brent SalisburyI have over 20 years of experience wearing various hats from, network engineer, architect, ops and software engineer. More at Brent's LinkedInView all posts by Brent Salisbury →

  1. MarkMark02-09-2015


    Thanks for posting this.

    When I reformat the code within IDEA, it produces formatted code that differs from go fmt. Significantly different, as if the formatter does not know about go fmt. Any tips on configuring this?

    • Alexander ZolotovAlexander Zolotov02-09-2015


      Hi Mark,

      At the moment the plugin doesn’t have a lot of formatting options. Feel free to file an issues about you code style preferences in Go.

      Meanwhile the plugin has an action that invoke real ‘go fmt’: https://www.dropbox.com/s/78d4tkk4ulsjsuw/Screenshot%202015-02-09%2017.16.41.png?dl=0

      • Brent SalisburyBrent Salisbury02-14-2015


        Hey Alexander! Will patch up the instructions, thanks for the fix. I meant to pop it into Gitter to get a review for errors, but time got away from me. I will also update it with the release page and update again when the 1.0 release drops. Thanks man!
        -Brent

        • Brent SalisburyBrent Salisbury03-11-2015


          Couple of updates Im jazzed about if you build the Alpha branch from trunk:


          -Refactor All Instances of a Go Element at Once Update


          Refactor All Instances of an Element at Once Update


          Syntax Highlighting Updates


          Syntax Highlighting Updates

  2. Alexander ZolotovAlexander Zolotov02-09-2015


    Hi Brent,

    Thank you for nice tutorial.

    Unfortunately, “Now we are all set to build the plugin.” step is wrong, the described action builds only intellij-go module without dependencies. This approach leads to many ClassNotFoundExceptions (especially in build >#11). You should build Go artifact instead (Build | Build Artifacts | Go.zip) and then use /bin/Go.zip for plugin installation.

    Also we’re going to publish weekly builds of 1.0.0.alpha branch here: https://github.com/go-lang-plugin-org/go-lang-idea-plugin/releases, so it won’t be necessarily to build plugin from source.