"src" folder changed to "pkg"

332 views
Skip to first unread message

Clitson Belleau

unread,
Sep 13, 2021, 7:35:22 PM9/13/21
to golang-nuts
Hi,

Has anyone had an issue with Go referencing "src" folders from the which was changed to "pkg" since v1.6? If so is there any way to fix this or any link to a similar issue? 

I couldn't find anything in the documentation regarding this. I am running the latest v1.17.1 release.

fig1.png
The folder listing for my GOPATH:
fig2.png

Thanks in advance,
Clitson

Ian Lance Taylor

unread,
Sep 13, 2021, 8:39:37 PM9/13/21
to Clitson Belleau, golang-nuts
When presenting text, please present it as ordinary text, not as images.  Text is much easier to read than images.  Thanks.

You should not have a directory $GOROOT/src/github.com.  I don't know why that appears to exist on your system.

Ian

Clitson Belleau

unread,
Sep 13, 2021, 10:22:52 PM9/13/21
to Ian Lance Taylor, golang-nuts
Noted with thanks.

I used "go get ." to download the package "github.com/google/gopacket", however Go is searching for it in "$GOPATH/src" while it was downloaded to "$GOPATH/pkg/mod".

--
Clitson

Anderson Queiroz

unread,
Sep 15, 2021, 3:56:51 AM9/15/21
to golang-nuts
If I'm not mistaken `$GOPATH/pkg/mod` where go modules keeps the downloaded modules, looking up `$GOPATH/pkg/mod` is to look for a module downloaded in module aware mode and `$GOPATH/src` is for gopath mode.

Are you working with go modules or on the legacy go path mode?

Clitson Belleau

unread,
Sep 16, 2021, 3:51:35 PM9/16/21
to golang-nuts
Alright, I got it fixed. As Anderson suggested, I ran go in legacy mode by manually setting GO111MODULE=off in win env var so I doesn't reset upon next instance of go (since it's a temporary variable). I also reinstalled git.

Thanks for the assist guys!
Reply all
Reply to author
Forward
Message has been deleted
0 new messages