dtra49684 2014-11-28 16:39
浏览 72

转到install:GOPATH以外的目录

I've just installed Go and I can't get my go install working. I followed a tutorial on YouTube to write a HelloWorld.go app but I keep getting the error:

go install: no install location for directory /Users/####/Documents/Dev/go/src/github.com/####/hello outside GOPATH

Here is my go env:

GOARCH="amd64"
GOBIN="/usr/local/go/bin"
GOCHAR="6"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/####/Documents/Dev/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fno-common"
CXX="clang++"
CGO_ENABLED="1"

In the tutorial that I was following the persons GOPATH was also set to a folder and then I was meant to create the folders /src/github.com/.....etc and then run go install in the directory with my code. Here's the code, although I imagine that not much could be wrong with the code:

package main

import "fmt"

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

When I run the pwd command inside the directory with my code, this is the output: /Users/####/Documents/Dev/go/src/github.com/####/hello

When I run the echo $GOPATH command inside the directory with my code, this is the output: /Users/####/Documents/Dev/go

I am running Mac OSX Yosemite.

  • 写回答

1条回答 默认 最新

  • douwei7501 2015-01-04 23:08
    关注

    I can think of two possibilities:

    1. GOBIN environment variable

    I'd suggest you read documentation about the go command, specifically the section on the GOPATH envvar. Quoting:

    The bin/ directory holds compiled commands. Each command is named for its source directory, but only the final element, not the entire path. That is, the command with source in DIR/src/foo/quux is installed into DIR/bin/quux, not DIR/bin/foo/quux. The foo/ is stripped so that you can add DIR/bin to your PATH to get at the installed commands. If the GOBIN environment variable is set, commands are installed to the directory it names instead of DIR/bin.

    Go is likely trying to install your program here, and running into permissions errors. Might just be a poor error message. In any case, it's unclear to me why you have $GOBIN set. To add the go tool to your PATH, add the directory directly: export PATH=/usr/local/go/bin:$PATH

    1. Case-insensitive filesystem

    If that doesn't work, check the case of your home directory, as was the problem in https://stackoverflow.com/a/27430341.

    评论

报告相同问题?

悬赏问题

  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 一直显示正在等待HID—ISP