doumeikuan6834 2014-10-01 05:57
浏览 468
已采纳

go install:GOPATH以外的目录没有安装位置

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:

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.

  • 写回答

2条回答 默认 最新

  • dongliang1941 2014-12-11 18:56
    关注

    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.

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

报告相同问题?

悬赏问题

  • ¥50 易语言把MYSQL数据库中的数据添加至组合框
  • ¥20 求数据集和代码#有偿答复
  • ¥15 关于下拉菜单选项关联的问题
  • ¥20 java-OJ-健康体检
  • ¥15 rs485的上拉下拉,不会对a-b<-200mv有影响吗,就是接受时,对判断逻辑0有影响吗
  • ¥15 使用phpstudy在云服务器上搭建个人网站
  • ¥15 应该如何判断含间隙的曲柄摇杆机构,轴与轴承是否发生了碰撞?
  • ¥15 vue3+express部署到nginx
  • ¥20 搭建pt1000三线制高精度测温电路
  • ¥15 使用Jdk8自带的算法,和Jdk11自带的加密结果会一样吗,不一样的话有什么解决方案,Jdk不能升级的情况