谁还没个明天 2013-08-09 14:52 采纳率: 50%
浏览 323
已采纳

去安装总是失败 GOPATH 以外没有安装目录

~/src/go-statsd-client> echo $GOPATH
/Users/me/gopath
~/src/go-statsd-client> echo $GOROOT
/usr/local/Cellar/go/1.1.1\
~/src/go-statsd-client> go install
go install: no install location for directory /Users/me/src/go-statsd-client outside GOPATH

No matter what structure the project is in this always fails with the same message. Go build works perfectly.

Here is my go env

GOARCH="amd64"
GOBIN=""
GOCHAR="6"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/me/gopath"
GORACE=""
GOROOT="/usr/local/Cellar/go/1.1.1"
GOTOOLDIR="/usr/local/Cellar/go/1.1.1/pkg/tool/darwin_amd64"
CC="gcc"
GOGCCFLAGS="-g -O2 -fPIC -m64 -pthread -fno-common"
CGO_ENABLED="1"

This is on Mac OSX Mountain Lion and go was installed with homebrew.

转载于:https://stackoverflow.com/questions/18149601/go-install-always-fails-no-install-directory-outside-gopath

  • 写回答

10条回答 默认 最新

  • perhaps? 2013-08-10 17:03
    关注

    When you provide no arguments to go install, it defaults to attempting to install the package in the current directory. The error message is telling you that it cannot do that, because the current directory isn't part of your $GOPATH.

    You can either:

    • Define $GOPATH to your $HOME (export GOPATH=$HOME).
    • Move your source to within the current $GOPATH (mv ~/src/go-statsd-client /User/me/gopath).

    After either, going into the go-statsd-client directory and typing go install will work, and so will typing go install go-statsd-client from anywhere in the filesystem. The built binaries will go into $GOPATH/bin.

    As an unrelated suggestion, you probably want to namespace your package with a domain name, to avoid name clashing (e.g. github.com/you/go-statsd-client, if that's where you hold your source code).

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(9条)

报告相同问题?

悬赏问题

  • ¥15 Stata 面板数据模型选择
  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 请问这个是什么意思?
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用