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.
- Open IntelliJ IDEA (menu) -> Preferences
- Press Plugins
- Press Browse Repositories
- Type Go in search field
- Choose Go in category Custom Languages.
- Press Install
- When plugin is installed, press Restart IntelliJ IDEA
Creating a project and configuring Go SDK
- Open File (menu) -> New -> Project…
- Choose Go
- Press Next
- Press Configure…
- Select home directory for Go SDK (usually /usr/local/go)
- Press Ok
- Press Next
- Choose project name and its location
- Press Finish
- If project directory does not exist, a small window will pop up
- Press Ok
Creating Hello World application
- Open File (menu) -> New -> Go File
- Name it hello
- Press OK
- Change file content to:
package main
import "fmt"
func main() {
fmt.Println("Hello World")
}
Building application
- Open Build (menu) -> Make Project
Running application
- Open Run (menu) -> Run
- Choose Go run hello.go
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.