gogo-microgoa

How to install Go package manually from source code


I'm living in China and is not able to download & install GO package through command (event I use the vpn network):

 go get -u <repo_url>

but I can access the repo_url and downloand its source code. So my question is can I put the scource code under src folder and run commamd ? :

go install 

if yes, what's the different betweeen the two way ?


Solution

  • for example, you have the repo_url at https://github.com/hello/example

    You can do go get manually by

    $ cd $GOPATH
    $ mkdir -p src/github.com/hello
    $ cd src/github.com/hello
    $ git clone https://github.com/hello/example.git
    $ cd example
    $ go install
    

    the binary will install into $GOPATH/bin

    if the go program of the repo_url depends on other go package. you have to manually get it and put it to correct path location too.