Golang on macOS 10.13.3

Hi all!
Help me please.
I have clean macOS 10.13.3

  1. Installing brew
  2. brew install go
  3. testing go - open terminal - command “go env” shows me
    GOPATH = /Users/user/go
    When on terminal i’m execude commands:
    export GOPATH=/Users/user/GoProj
  • go env shows me GOPATH=/Users/user/GoProj
    when i’m open new session on terminal go env result GOPATH = /Users/user/go

When i’m open myproj from github in folder GOPATH=/Users/user/GoProj - library’s golang like “fmt” not available

And in /user folder not exist ~/.bash_profile
When i’m created them with current GOROOT and GOPATH - all commands not avaliable in terminal like:
sudo
nano
and etc.

How correct setting GOPATH or create new current ./bash_profile ?
Thanks a lot!

Put this in ~/.bash_profile:

export GOROOT=$(go env GOROOT)
export GOPATH=$(go env GOPATH)
export PATH=$GOPATH/bin:$GOROOT/bin:$PATH

Then open new terminal.

In ~/go you have to create subfolder src and then your project name like GoProj.

1 Like

All done
But in IntellijIDEA all libraryes go - not visible in project(
And after “invalidate caches and restart” nothing changes

independencies in project include with glide in vendor folder
When in idea i turn on setting - Enabled vendoring - project see dependencies
all but without standart go libraries

Libraries are stored outside of the project folder, but I am not so familiar with IntelliJ.

Depending on how one starts IntelliJ it won’t pick up the variables from .bash_profile.

Variables set in that file are only visible in bash and child processes. So IntelliJ will only know about altered variables if its started from the bash.

If its started from the GUI, it will inherit thats environment.

Also, back in the days when I used IntelliJ (for other languages) they often ignored settings from the environment and let you choose an “SDK” per project. Even though the field is labeled SDK it meant compiler and stdlib version to use for any language.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.