GOPATH error in windows "GOPATH entry is relative; must be absolute path: "

huangapple go评论94阅读模式
英文:

GOPATH error in windows "GOPATH entry is relative; must be absolute path: "

问题

我是你的中文翻译助手,以下是翻译好的内容:

我刚开始学习GO,在Windows上初始化GOPATH时遇到了一个错误。我的项目文件夹路径是:

C:\Users\kamin\Documents\pm-manager

我尝试在环境变量中设置路径(GOPATH),但是出现了错误:
go: GOPATH条目是相对路径;必须是绝对路径:":/cygdrive/c/Users/kamin/Documents/pm-manager\r\r"。
运行'go help gopath'获取用法信息。

英文:

I am new to GO and getting an error when initializing GOPATH in windows.
In my project folder is

C:\Users\kamin\Documents\pm-manager

and i am try to set path in environment variable (GOPATH)but it is getting an error
go: GOPATH entry is relative; must be absolute path: ":/cygdrive/c/Users/kamin/Documents/pm-manager\r\r".
Run 'go help gopath' for usage.

答案1

得分: 15

遇到了同样的问题。解决方法很简单:只需在整个路径名前指定驱动器。问题出现的原因是我按照 Go 的“入门指南”页面上的说明设置了 GOPATH=%HOMEPATH%\Work。问题在于 %HOMEPATH% 被定义为相对路径(\Users\MyName),所以 GOPATH 现在指向了 \Users\MyName\Work。我只需要设置 GOPATH=c:\Users\MyName\Work,错误就会消失。

英文:

Ran into same problem. Fix is quite simple: just specify the drive in front of the entire path name. The issue occurred because I was following the instructions on Go "Getting Started" page and set GOPATH=%HOMEPATH%\Work . The problem was that %HOMEPATH% was defined as a relative path (\Users\MyName), and so GOPATH now pointed to \Users\MyName\Work . All I needed to do was set GOPATH=c:\Users\MyName\Work and the error goes away.

答案2

得分: 7

我遇到了同样的问题。我的Go版本是go1.9.1 windows/amd64
然而,我通过删除GOPATH末尾的分号来解决了这个问题。
GOPATH error in windows "GOPATH entry is relative; must be absolute path: "

英文:

I encountered the same problem. My go version is go1.9.1 windows/amd64.
However I fixed the problem by deleting the simucolon end of the GOPATH.
GOPATH error in windows "GOPATH entry is relative; must be absolute path: "

答案3

得分: 1

作为替代方案,您可以在Windows 10下将其设置为%USERPROFILE%<GO_DIRECTORY>。

英文:

As alternative you can set it to %USERPROFILE%<GO_DIRECTORY> under Windows 10

答案4

得分: 1

你可以使用Cygwin来设置这个案例的Go路径。

将GOPATH导出为'c:\folder\folder\folder'。

对于Cygwin,需要在字符串'c:\path'中使用。

通常你可以尝试使用/cygdrive/.../...,但对于Go来说不可行(需要c:\或其他驱动器)。

英文:

you can put this case uses cygwin this go path

export GOPATH='c:\folder\folder\folder'

for cygwin is necessary in string 'c:\path'

normaly you try use /cygdrive/.../...

but for GO is not possible ( need c:\ or other drive )

答案5

得分: 1

我遇到的另一个错误案例是在设置GOPATH时犯了一个愚蠢的错误。

我添加了:D\Go(忘记在驱动器字母后添加冒号)。
正确的应该是D:\Go,当然这样解决了错误。

英文:

Adding one more error case that I experienced, was a silly-silly mistake in setting the GOPATH.

I added : D\Go (Forgot to added the colons after Drive letter).
Correct should have been D:\Go, Offcourse this resolved the error.

huangapple
  • 本文由 发表于 2016年3月9日 14:57:49
  • 转载请务必保留本文链接:https://go.coder-hub.com/35884965.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定