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

前端 未结 25 2938
死守一世寂寞
死守一世寂寞 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:03

    You have to update the PATH based on the terminal(bash or zsh) which you use.

    1. Open the shell script file of the terminal i.e ~/.bashrc or ~/.zshrc in an editor
       vi ~/.zshrc
          (or)
       code ~/.zshrc
    
    1. Update the below GOPATH if already found or add the below line.

    export GOPATH=$HOME/go:/$HOME/projects/go

    Here you can add one or more paths separated by a semicolon : from different locations of your GO projects on the system to the GOPATH environment variable i.e /path/1:path/2:path/3 etc.

    In my case, I have added 2 paths, as shown above, one from the root $HOME/go and the other one from the projects directory :/$HOME/projects/go

提交回复
热议问题