How do I SET the GOPATH environment variable on Ubuntu? What file must I edit?

前端 未结 25 2940
死守一世寂寞
死守一世寂寞 2020-11-28 00:45

I am trying to do a go get:

go get github.com/go-sql-driver/mysql

and it fails with the following error:

packa         


        
25条回答
  •  攒了一身酷
    2020-11-28 01:09

    As written in the official instructions:

    The GOPATH environment variable specifies the location of your workspace. It defaults to a directory named go inside your home directory, so $HOME/go on Unix, $home/go on Plan 9, and %USERPROFILE%\go (usually C:\Users\YourName\go) on Windows. If you would like to work in a different location, you will need to set GOPATH to the path to that directory. (Another common setup is to set GOPATH=$HOME.) Note that GOPATH must not be the same path as your Go installation.

    So for example, if you are coding in Jetbrains Webstorm (using the Go plugin), you might want to set GOPATH as /Users//WebstormProjects.

    In simpler words, set it to wherever you want your Go projects to reside.

提交回复
热议问题