moovweb / gvm

Go Version Manager
http://github.com/moovweb/gvm
MIT License
10.18k stars 533 forks source link

No GOBIN cause go install failed #349

Open doggy8088 opened 4 years ago

doggy8088 commented 4 years ago

Here are the steps reproduce my problem:

  1. install & use & env

    gvm install go1.14.6
    gvm use go1.14.6
    go env
  2. The GOBIN="" is empty.

    I know the GOBIN's default value is $GOPATH/bin by default. But I can't run go install to install my command to $GOPATH/bin.

  3. sample app & go install

    mkdir test1 && cd test1
    cat <<EOF > main.go
    package main
    import "fmt"
    func main() {
    fmt.Println("Hello")
    }
    EOF
    
    go install

    I'll get this:

    ~/test1$ go install
    go install: no install location for directory /home/will/test1 outside GOPATH
            For more details see: 'go help gopath'
  4. When setup GOBIN env variable, all problem gone.

    export GOBIN=$GOPATH/bin
    go install