How To Install Go Plugin For IntelliJ Idea 15

There is a number of good tools that support Go developers in writing code. But three of them are the most popular in the field: Vim, Sublime, IntelliJ Idea. I use all of them, but the most feature rich and my favourite one is IntelliJ Idea. In this post we will set up Intellij Idea for development in Go.

Installing Go

If you have not done it yet, follow installation instructions from Go official website.

Installing IntelliJ Idea 15

If Idea is not installed, download and install it from IntelliJ Idea website.

Installing Go Plugin for Idea

Go plugin is an IntelliJ Idea plugin that simplifies writing code in Golang and provides some refactorings. Below is a detailed instruction on how to set it up.

  1. Open IntelliJ IDEA (menu) -> Preferences
  2. Press Plugins Idea Preferences Plugins
  3. Press Browse Repositories
  4. Type Go in search field
  5. Choose Go in category Custom Languages. Idea Browse Repositories
  6. Press Install
  7. When plugin is installed, press Restart IntelliJ IDEA

Creating a project and configuring Go SDK

  1. Open File (menu) -> New -> Project…
  2. Choose Go Create new Go project
  3. Press Next
  4. Press Configure…
  5. Select home directory for Go SDK (usually /usr/local/go) Configure Go SDK
  6. Press Ok
  7. Press Next
  8. Choose project name and its location Set project details
  9. Press Finish
  10. If project directory does not exist, a small window will pop up Directory creation confirmation
  11. Press Ok

Creating Hello World application

  1. Open File (menu) -> New -> Go File
  2. Name it hello New file
  3. Press OK
  4. Change file content to:
package main

import "fmt"

func main() {
	fmt.Println("Hello World")
}

Building application

  1. Open Build (menu) -> Make Project

Running application

  1. Open Run (menu) -> Run
  2. Choose Go run hello.go Run window

IntelliJ Idea output:

/usr/local/go/bin/go run /Users/yury/projects/go/src/hello/hello.go
Hello World

Bottom line

Configuring Intellij Idea to support development in Go is not a breeze yet, especially if you do not have prior Idea experience. But after short pain, you get the best tool support for Go in action. Especially you will love Idea if you refactor often. Idea provides lot of short cuts for many tasks like compile, run, create new file and so on - use them.