$GOPATH/go.mod exists but should not

675 views
Skip to first unread message

joseph.p...@gmail.com

unread,
Jan 10, 2021, 7:59:55 PM1/10/21
to golang-nuts
I found (what I think is) a simple GO project to play with as a learning exercise:


The second step fails immediately. with the aforementioned error message.

I'm using GO version 1.15.6
$GOPATH is undefined.
Here's the content of ~/go

Joes-iMac:go joe$ pwd

/Users/joe/go

Joes-iMac:go joe$ ls

bin go.mod pkg src

Joes-iMac:go joe$ more go.mod

module urlShorter


go 1.15

[eof]

So, I googled for the error message. I find lots of hits, but no clear explanation of why the error message, but most importantly, no clear explanation of how to fix...

Help please!

Thanks,

Joe

Rick

unread,
Jan 10, 2021, 8:24:24 PM1/10/21
to golang-nuts
I'm not entirely following what you are doing. But here are some comments. You have a directory $HOME/go, the contents of which look like what you would see under $GOPATH. If you are going to create a project under $HOME/go (whether GOPATH is defined or not), the suggested place to put it is in $HOME/go/src/urlShortener or perhaps $HOME/go/src/github.com/yourID/urlShortener. Having said that, using the same version of Go I am able to do the following without error:

unset GOPATH
cd /tmp
mkdir urlShortener
cd urlShortener
go mod init urlShortener
etc...

Works for me.

JOE MCGUCKIN

unread,
Jan 10, 2021, 10:23:36 PM1/10/21
to Rick, golang-nuts
OK,  I was doing everything in the ~/go directory. I assumed that 'go get’ would create the appropriate directories under go/src.

I have not followed your example yet, but I suspect that’s my problem.

Thanks!

Joe

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/f0b5be67-a41d-4953-b65a-102309a232d4n%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages