dongshengheng1013 2014-04-18 11:31
浏览 12
已采纳

无法“安装”在OSX上运行

I'm having a look at Go however i'm stuck at the very first hurdle. Whenever I run 'go install' I get the following error:

go install: no install location for directory /Users/jamie/Sites/gocode/src/jd/hello outside GOPATH

In all of the other posts I've seen about this it's usually because the user hasn't set a GOPATH or is trying to run go install outside of the GOPATH. I have set up my GOPATH and my code is in my GOPATH.

Here is my directory structure:

/Users/jamie/Sites/gocode
    /bin
    /src
        /jd
            /hello
                hello.go

I'm trying to run 'go install' from inside /Users/jamie/Sites/gocode/src/jd/hello. Here is my GOPATH:

$ echo $GOPATH
/Users/james/Sites/gocode

And finally here is hello.go:

package main

import "fmt"

func main() {
    fmt.Println("Hello there")
}

What am I doing wrong here?

Edit: go env:

$ go env
GOARCH="386"
GOBIN=""
GOCHAR="8"
GOEXE=""
GOHOSTARCH="386"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/james/Sites/gocode"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_386"
TERM="dumb"
CC="gcc"
GOGCCFLAGS="-g -O2 -fPIC -m32 -pthread -fno-common"
CXX="g++"
CGO_ENABLED="1"

Thanks!

  • 写回答

1条回答 默认 最新

  • donglu5041 2014-04-18 12:43
    关注

    Your GOPATH="/Users/james/Sites/gocode" wheras your code is in /Users/jamie/Sites/gocode/src/jd/hello

    So set GOPATH=/Users/jamie/Sites/gocode and hopefully it will work fine.

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

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog