M
M
Mikhail Osher2017-01-21 15:35:04
go
Mikhail Osher, 2017-01-21 15:35:04

How to properly set up an IDE to work with golang?

Here is what I have:
- OSX Sierra 10.12.2
- Idea Ultimate 2016.3.3
- go version go1.7.4 darwin/amd64
- Go plugin for Idea (Version 0.13.1924)
Here is what I understood from golang documentation:
- GOROOT = path to go binaries
- GOPATH = path to the project folder, inside which the src folder should be
. I use zsh, the above environment variables have not been added anywhere yet.
Here are the project settings now. I guess there is something to be added here as well.
A question for the experts: what should be written where correctly in order to work painlessly with go?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
X
xotkot, 2017-01-21
@miraage

You write the paths to the installed go:
(for example, if go is installed in the $HOME/go folder )

$ export GOROOT=$HOME/go
$ export PATH=$PATH:$GOROOT/bin

Next, create a workspace:
$ export GOPATH="$HOME/work"
$ export GOBIN="$GOPATH/bin"
$ mkdir -p $GOPATH/src
$ mkdir $GOBIN

so that every time after restarting the terminal you do not need to prescribe variables again, we add exports ( export ...) to the end of the ~./.zshrc file (for bash it is ~/.bashrc)
Now you move your go projects to the $ HOME/work/src
folder to view go variables, use the command:
$ go env

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question