* Alexander Mills <alexander.d.mi...@gmail.com> [210119 16:54]:
> i am getting this weird error message:
> 
>  package twitch/go-scripts/dynamo-creators-to-s3/lib is not in GOROOT 
> (/usr/local/Cellar/go/1.15.6/libexec/src/twitch/go-scripts/dynamo-creators-to-s3/lib)
> 
> my GOPATH=$PWD/scripts/go
> 
> so there is only 1 GOPATH
> 
> [image: Screen Shot 2021-01-19 at 1.52.30 PM.png]

The error message is really incomplete, and therefore confusing.  It
should be "package ... is not in GOROOT or any element of GOPATH".

I had written an answer based on an environment using GOPATH before
carefully looking at your screenshot (please paste text rather than
using screenshots).  It seems you have a go.mod file, so GOPATH is not
relevant.

If using modules rather than GOPATH, the error message is probably
correct, as GOPATH is not used except as a place to cache downloaded
modules under the "$GOPATH/pkg" directory.

As best as I can tell (and I am still using GOPATH, so I may be
completely wrong), a Go program in a module can only use web-aware
import paths (except for standard library packages).  Perhaps someone
else can clarify that, and how to set up your directory structure.  I
think there was recent thread with a similar problem, but I did not pay
much attention to it.

Personally, I think that requiring (as opposed to allowing) web-aware
import paths is a terrible (no, I mean really, really terrible) design.

On the other hand, if you were intending to use GOPATH, but it was
incorrectly set and so the go tool kindly (???) created a go.mod file
for you, I can probably help you figure out your problem.  First, erase
go.mod.  Then, ensure GOPATH is what you expect (use "go env GOPATH",
rather than "echo $GOPATH").  If that doesn't lead you to an answer,
post the output from go env and the go command you are using that gives
the error (go build, go test, etc.).

...Marvin

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/20210120135843.rtxdxzbql5hkx3gn%40basil.wdw.

Reply via email to