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!

图片转代码服务由CSDN问答提供 功能建议

我正在查看Go,但是我遇到了第一个障碍。 每当我运行“执行安装”时,都会出现以下错误:

 执行安装:目录/ Users / jamie / Sites / gocode / src / jd / hello外部没有安装位置 GOPATH 
   
 
 

在我看到的所有其他帖子中,这通常是因为用户尚未设置GOPATH或正在尝试在其他地方运行go install GOPATH。 我已经设置好我的GOPATH,我的代码在我的GOPATH中。

这是我的目录结构:

  / Users / jamie / 网站/ gocode 
 / bin 
 / src 
 / jd 
 / hello 
 hello.go 
   
 
 

我正在尝试运行“开始安装” 从/ Users / jamie / Sites / gocode / src / jd / hello内部。 这是我的GOPATH:

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

最后是hello.go:

 包main 
 
import“ fmt” 
 
func main(){
 fmt.Println(“ H​​ello there”)  
} 
   
 
 

我在这里做什么错了?

编辑:转到环境: \ n

  $ go env 
GOARCH =“ 386” 
GOBIN =“” 
GOCHAR =“ 8” 
GOEXE =“” 
GOHOSTARCH =“ 386” 
GOHOSTOS =“ darwin” 
GOOS =“ darwin”  
GOPATH = “/用户/詹姆斯/网站/ gocode” 
GORACE = “” 
GOROOT = “在/ usr /本地/去” 
GOTOOLDIR = “在/ usr /本地/去/包装/工具/ darwin_386” \ NTERM =”  dumb“ 
CC =” gcc“ 
GOGCCFLAGS =”-g -O2 -fPIC -m32 -pthread -fno-common“ 
CXX =” g ++“ 
CGO_ENABLED =” 1“ 
   \  n 
 

谢谢!

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 收藏
  • 邀请回答

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.

    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题