Sandun Tharaka
Sandun Tharaka

Reputation: 747

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

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.

Upvotes: 19

Views: 27990

Answers (6)

jkemboe
jkemboe

Reputation: 1

How I solved this problem:

When you set the GOPATH in windows via commandline:

Remember to insert single quote on export path:

  • Instead of: export GOPATH=C:\<Your Go Path> Use this: export GOPATH='C:\<Your Go Path>'
  • Using double quotes will not work as it will format incorrectly: export GOPATH="C:\<Your Go Path>"

Upvotes: 0

sud007
sud007

Reputation: 6141

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.

Upvotes: 1

pigLoveRabbit520
pigLoveRabbit520

Reputation: 523

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. enter image description here

Upvotes: 7

Taranttini
Taranttini

Reputation: 1435

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 )

Upvotes: 1

Homero Fonseca
Homero Fonseca

Reputation: 11

As alternative you can set it to %USERPROFILE%\ under Windows 10

Upvotes: 1

LNI
LNI

Reputation: 3181

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.

Upvotes: 15

Related Questions