0

When I run my cat .bash_profile command via terminal the following message is displayed:

export GOPATH=c:/Users/Petey/Documents/go

I cd into the above, create a main.go and attempt to execute with go run main.go, but I receive this error. What am I doing incorrectly?

go: GOPATH entry is relative; must be absolute path: "c".

7
  • Which terminal are you using ? according to this question, it should be c:\Users\Petey\ instead of c:/Users/Petey/ Commented Sep 29, 2017 at 2:08
  • and don't forget to enclose with single quote (e.g export GOPATH='C:\Users\Petey'). Commented Sep 29, 2017 at 2:11
  • Peters-MacBook-Air:go Petey$ cat .bash_profile export GOPATH=c:\Users\Petey\Documents\go this is my bash profile pwd however, when I run a go file still the same error of path must be relative. Commented Sep 29, 2017 at 2:23
  • once you have a working GOPATH you may want its children dirs : pkg, src, bin as per golang.org/doc/code.html Commented Sep 29, 2017 at 2:32
  • 1
    So to be clear, you're not using Microsoft Windows but macOS? In that case I don't quite follow why you're using a Windows path starting with a drive letter? Also, since Go 1.8 the GOPATH is automatically set to $HOME/go, so you may not need to set it yourself at all! Commented Sep 29, 2017 at 20:53

1 Answer 1

1

You should quote the path like so: export GOPATH="C:/Users/Petey/Documents/go"

Since it is Windows bash, you could also try: export GOPATH="/mnt/c/Users/Petey/Documents/go"

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.