- Yair Mark
When I started working on Go a few weeks ago at first I switched to the IDE I use the most: IntelliJ. I installed the Go plugin but found the IDE was not giving me any intellisense and was incorrectly classifying things as errors when they were not. This in hindsight may have been due to my GOPATH and GOROOT not being configured properly.
But anyway between then and now I eventually settled on VS code which is fairly light and with a bit of configuration also gives me:
- Go syntax highlighting
- Go intellisense
- Go linting and error highlighting
At this stage you should already have installed Go and setup the various Go environment variables you need if not refer to my article on setting up
dep (Go's dependency manager).
The first thing we need to setup is the completion server called You Complete Me:
- Clone the repo here.
- Follow the building section in the readme.
- You should already have the GoLang compiler installed, if not install it.
- For MacOS the equivalent for the line
sudo apt install build-essential cmake python-devshould be:
brew install cmake
brew install python, homebrew should include the development headers already.
brew reinstall pythonif you already had Python pre-installed (i.e not using Homebrew)
- for the bit when you call the
setup.pyuse the following instead to target only Go and C:
./build.py --clang-completer --gocode-completer.
Setup VS Code:
- Install the official Go plugin.
- After installing this when you open a go file for the first time in VS code it will prompt you to install a number of Go dependencies. Select "install all" - this will install all the basic Go development tools it needs like the linter (onto your GOPATH)
- Install the You Complete Me plugin for vs code.
- configure the plugin by pushing
ctrl/cmd+,then in the user settings section add the following to the end of your settings (tweak as needed for your particular environment):
"ycmd.path": "/path/to/cloned/ycmd", "ycmd.enabled_languages": ["go"], "ycmd.lint_run": "onSave"
- Finally close and re-open VS Code and you should now get intellisense when you type