$GOPATH 已设置但 go install 不起作用
$GOPATH is set but go install does not work
我试图了解 go 环境,但我似乎无法 go install
我 git 在本地克隆的任何包。 go install
在 hello world 示例上工作正常。
~GOPATH/src/go-github(master ✔) go install -i go-github/github
~GOPATH/src/go-github(master ✔)
~GOPATH/src/go-github(master ✔)
~GOPATH/src/go-github(master ✔) ll ~GOBIN
total 80992
-rwxr-xr-x 1 drez 1896053708 6.2M Sep 21 14:57 basicauth
-rwxr-xr-x 1 drez 1896053708 6.3M Sep 21 14:57 commitpr
-rwxr-xr-x 1 drez 1896053708 6.3M Sep 21 14:57 fields
-rwxr-xr-x 1 drez 1896053708 1.9M Sep 21 14:06 hello
-rwxr-xr-x 1 drez 1896053708 6.2M Sep 21 14:57 migrations
-rwxr-xr-x 1 drez 1896053708 6.3M Sep 21 14:57 newrepo
-rwxr-xr-x 1 drez 1896053708 6.3M Sep 21 14:57 simple
我的go env
输出如下:
~GOPATH/src/go-github(master ✔) go env
GOARCH="amd64"
GOBIN="/Users/drez/Dev/golang/bin"
GOCACHE="/Users/drez/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/drez/Dev/golang"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/f7/zq9bg2ds6671wp4s7v3vkyf5rzyx5d/T/go-build744915712=/tmp/go-build -gno-record-gcc-switches -fno-common"
$PATH 以 $GOBIN 结尾:
~GOPATH/src/go-github(master ✔) echo $PATH /Users/drez/.toolbox/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/go/bin:/Users/drez/.toolbox/bin:/Users/drez/Library/Android/sdk/platform-tools:/Library/Frameworks/Python.framework/Versions/3.6/bin:/Library/Frameworks/Python.framework/Versions/3.5/bin:/Users/drez/Library/Android/sdk/platform-tools:/Users/drez/Dev/golang/bin
go install
命令用于将二进制文件安装到工作区的 bin 目录或 go clean -i
删除它。
如果你想下载一个库来解析你的导入,你需要使用 go get
命令。
此外,考虑到只能安装 main
包
我试图了解 go 环境,但我似乎无法 go install
我 git 在本地克隆的任何包。 go install
在 hello world 示例上工作正常。
~GOPATH/src/go-github(master ✔) go install -i go-github/github
~GOPATH/src/go-github(master ✔)
~GOPATH/src/go-github(master ✔)
~GOPATH/src/go-github(master ✔) ll ~GOBIN
total 80992
-rwxr-xr-x 1 drez 1896053708 6.2M Sep 21 14:57 basicauth
-rwxr-xr-x 1 drez 1896053708 6.3M Sep 21 14:57 commitpr
-rwxr-xr-x 1 drez 1896053708 6.3M Sep 21 14:57 fields
-rwxr-xr-x 1 drez 1896053708 1.9M Sep 21 14:06 hello
-rwxr-xr-x 1 drez 1896053708 6.2M Sep 21 14:57 migrations
-rwxr-xr-x 1 drez 1896053708 6.3M Sep 21 14:57 newrepo
-rwxr-xr-x 1 drez 1896053708 6.3M Sep 21 14:57 simple
我的go env
输出如下:
~GOPATH/src/go-github(master ✔) go env
GOARCH="amd64"
GOBIN="/Users/drez/Dev/golang/bin"
GOCACHE="/Users/drez/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/drez/Dev/golang"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/f7/zq9bg2ds6671wp4s7v3vkyf5rzyx5d/T/go-build744915712=/tmp/go-build -gno-record-gcc-switches -fno-common"
$PATH 以 $GOBIN 结尾:
~GOPATH/src/go-github(master ✔) echo $PATH /Users/drez/.toolbox/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/go/bin:/Users/drez/.toolbox/bin:/Users/drez/Library/Android/sdk/platform-tools:/Library/Frameworks/Python.framework/Versions/3.6/bin:/Library/Frameworks/Python.framework/Versions/3.5/bin:/Users/drez/Library/Android/sdk/platform-tools:/Users/drez/Dev/golang/bin
go install
命令用于将二进制文件安装到工作区的 bin 目录或 go clean -i
删除它。
如果你想下载一个库来解析你的导入,你需要使用 go get
命令。
此外,考虑到只能安装 main
包