/ Go

Configuring Visual Studio Code for Go

I'm doing quite a few Go programming these days in Visual Studio Code for Mac and find the following approach to running it quite useful:

  1. Add the plugin "Go" to rich language support.

  2. Create folder SDK/golang-vscode/bin in user's folder: mkdir -p ~/SDK/golang-vscode/bin.

  3. Add this folder to the path environment variable by running the command export PATH=$PATH:~/SDK/golang-vscode/bin and then adding it to ~/.bash_profile.

  4. Create ~/SDK/golang-vscode/bin/vscodego:


GOPATH=`pwd` PATH=$PATH:`pwd`/bin code `pwd` $*
  1. Navigate to ~/SDK/golang-vscode and run vscodego test.go. Editor should ask whether to install tools, click Install.

Now in any Golang project's folder run vscodego and Visual Studio Code should open with GOPATH set to the current folder and bin subfolder in the path.

And you can run vscodego from different folders and work on two projects in the same time with correct GOPATH set for each editor window.

Alex Netkachov

Alex Netkachov

Alex likes functional programming, algorithms and code reviews. Apart from programming, his favourites are walking with his family in the parks and national trails and reading books.

Read More

Why not to stay updated if the subject is interesting? Join Telegram channel Alex@Net or follow alex_at_net on Twitter. Or just, use the comments form below.