duaevb1511 2018-09-28 21:29
浏览 61
已采纳

已设置$ GOPATH,但无法安装

I am trying to understand the go environment, but I can't seem to go install any package I git cloned locally. go install on the hello world example works fine.

~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

My go env output is as follows:

~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 with $GOBIN at the end:

~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
  • 写回答

1条回答 默认 最新

  • doswy02440 2018-09-28 21:39
    关注

    go install command is for installing binary into your workspace's bin directory or go clean -i to remove it.

    If you want to download a lib to resolve your imports you need to use go get command.

    Also, consider that only the main packages can be installed

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 麒麟V10桌面版SP1如何配置bonding
  • ¥15 Marscode IDE 如何预览新建的 HTML 文件
  • ¥15 K8S部署二进制集群过程中calico一直报错
  • ¥15 java python或者任何一种编程语言复刻一个网页
  • ¥20 如何通过代码传输视频到亚马逊平台
  • ¥15 php查询mysql数据库并显示至下拉列表中
  • ¥15 freertos下使用外部中断失效
  • ¥15 输入的char字符转为int类型,不是对应的ascall码,如何才能使之转换为对应ascall码?或者使输入的char字符可以正常与其他字符比较?
  • ¥15 devserver配置完 启动服务 无法访问static上的资源
  • ¥15 解决websocket跟c#客户端通信