去安装:没有GOPATH以外目录的安装位置 [英] go install: no install location for directory outside GOPATH

查看:946
本文介绍了去安装:没有GOPATH以外目录的安装位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,我已经看到这个问题出现了很多,但没有解决方案为我工作。我已经尝试了无数次来解决这个问题,但没有。以下是我所做的:


  • 安装了Go。


$ b $然后,我将路径需求添加到我的 .bash_profile


  • 导出PATH = $ PATH:/ usr / local / go / bin

  • export GOPATH = $ HOME / go



然后设置正确的文件夹:



正如您所看到的,我还创建了一个名为轮胎



main.go 的内容很简单:

  package main 

importfmt

func main(){
fmt.Println(Hello ,world!)
}

我会认为这就是所有你需要的东西工作正常,但不管我做什么,当我尝试运行 go install 时,我总是遇到以下错误:



go install:没有安装位置目录/ Users / Daryl / go / src / tire GOPATH



我知道我可以运行 go install tire ,但这不是问题。我宁愿知道发生了什么。



以下是我运行 go env 时得到的结果:

  GOARCH =amd64
GOBIN =
GOCHAR =6
GOEXE =
GOHOSTARCH =amd64
GOHOSTOS =darwin
GOOS =darwin
GOPATH =/ Users / daryl / go
GORACE =
GOROOT =/ usr / local / go
GOTOOLDIR =/ usr / local / go / pkg / tool / darwin_amd64
TERM =dumb
CC = clang
GOGCCFLAGS = - g -O2 -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fno-common
CXX =clang ++
CGO_ENABLED = 1

这对你们中的任何人都很熟悉吗?我错过了什么?任何帮助将不胜感激。

解决方案

问题出在James Henstridge 评论,出于某种原因,我的用户目录名称大小写有问题。即使目录小写字母,我也必须使其大写。



这有效:



GOPATH = / Users / Daryl / go



没有:



GOPATH = $ HOME / go



然而,从我的iMac开始,我在设置Go时没有任何问题,所以到目前为止,我不确定发生了什么事情,但是在这种情况下,大写解决了它。


Ok, I've seen this question pop up a lot, but no solutions are working for me. I've tried countless times to solve this issue, but nothing. Here's what I have done:

  • Installed Go.

I then added path requirements to my .bash_profile:

  • export PATH=$PATH:/usr/local/go/bin
  • export GOPATH=$HOME/go

I then setup the correct folders:

As you can see, I also created a projected called tire.

The contents for main.go are simply:

package main

import "fmt"

func main() {
  fmt.Println("Hello, world!")
}

I would assume this is all you need to get things working correctly, but no matter what I do, I always get the following error when I try to run go install:

go install: no install location for directory /Users/Daryl/go/src/tire outside GOPATH

I know I could just run go install tire, but that's not the issue. I'd rather know what's going on.

Here's what I get when I run go env:

GOARCH="amd64"
GOBIN=""
GOCHAR="6"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/daryl/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
TERM="dumb"
CC="clang"
GOGCCFLAGS="-g -O2 -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fno-common"
CXX="clang++"
CGO_ENABLED="1"

Is this familiar to any of you? Did I miss something? Any help would be appreciated.

解决方案

The problem was as James Henstridge commented, for some reason there was an issue with my user directory name case. Even though the directory is lowercase, I had to make it capitalized.

This worked:

GOPATH=/Users/Daryl/go

This didn't:

GOPATH=$HOME/go

However, since moving to a rMBP from my iMac, I had no problems whatsoever setting up Go, so, to this day, I'm not sure what was going on, but in that instance the capitalization fixed it.

这篇关于去安装:没有GOPATH以外目录的安装位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆