Skip to content

Down with the sickness (AUTO_GOPATH)#48958

Merged
thaJeztah merged 1 commit intomoby:masterfrom
cpuguy83:autogo_to_the_future
Jan 2, 2025
Merged

Down with the sickness (AUTO_GOPATH)#48958
thaJeztah merged 1 commit intomoby:masterfrom
cpuguy83:autogo_to_the_future

Conversation

@cpuguy83
Copy link
Copy Markdown
Member

@cpuguy83 cpuguy83 commented Nov 26, 2024

Go has a nice tool to inspect the currently set (or default) GOPATH with go env GOPATH.
We should do that rather than absolutely requiring people to manually set GOPATH or use AUTO_GOPATH.

This doesn't actually remove AUTO_GOPATH, people can still use it.

@cpuguy83 cpuguy83 requested a review from tianon as a code owner November 26, 2024 17:07
@cpuguy83 cpuguy83 force-pushed the autogo_to_the_future branch 2 times, most recently from 8bacbb9 to 58ab44b Compare November 26, 2024 17:46
tianon
tianon previously approved these changes Nov 26, 2024
Copy link
Copy Markdown
Member

@tianon tianon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is sane, but honestly removing all this code would be too IMO (assuming we go build with -mod but IIRC we aren't quite there yet?)

@tianon
Copy link
Copy Markdown
Member

tianon commented Nov 26, 2024

(to be clear, I'm a big fan of GOPATH and real mad it's dead, but no sense mourning it)

@thaJeztah
Copy link
Copy Markdown
Member

Yeah, I locally have symlinked go.mod -> vendor.mod and go.sum -> vendor.sum, which may not be entirely correct, but it works OK (keeps my IDE happy, and not having to GO111MODULE=off when you least expect it.

I guess we could even add that as extra condition (instead of erroring) ("is there a go.mod?")

@thaJeztah thaJeztah added status/4-merge kind/enhancement Enhancements are not bugs or new features but can improve usability or performance. area/project labels Nov 27, 2024
@thaJeztah thaJeztah added this to the 28.0.0 milestone Nov 27, 2024
Comment thread hack/make.sh Outdated
fi

if [ ! "$GOPATH" ]; then
if [ ! "$GOPATH" ] && [ ! "$(go env GOPATH)" ]; then
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Silly question; wouldn't the first check be redundant? (i.e., wouldn't go env GOPATH reflect GOPATH (if set)?)

Copy link
Copy Markdown
Member

@thaJeztah thaJeztah Nov 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LOL, actually wondering now if it's possible to not have GOPATH;

root@f0c269d1aafd:/go# printenv GOPATH
/go
root@f0c269d1aafd:/go# go env GOPATH
/go
root@f0c269d1aafd:/go# export GOPATH=/foo/bar
root@f0c269d1aafd:/go# go env GOPATH
/foo/bar
root@f0c269d1aafd:/go# unset GOPATH
root@f0c269d1aafd:/go# go env GOPATH
/root/go

wondering now if the check .. actually checks for what it was meant to check; given that go env GOPATH always returns a value, and if no custom path is set, it uses default (~/go/), it would never be "true"?

Wondering if the check was originally meant to say “as long as it’s not the default (because of vendoring when it was not a thing yet)?). If that’s not the case, wondering if the check is even needed (if it would pick a default if not set)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh fair point 🤔

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, I think I was just keeping it because it already existed.

I have removed this.

@tianon tianon dismissed their stale review December 10, 2024 17:28

this won't actually work as-is because go env GOPATH will always return a non-empty value 🙈

@cpuguy83 cpuguy83 force-pushed the autogo_to_the_future branch from 58ab44b to 9270df6 Compare January 2, 2025 19:36
Go has a nice tool to inspect the currently set (or default) `GOPATH`
with `go env GOPATH`.
We should do that rather than absolutely requiring people to manually
set `GOPATH` or use the `AUTO_GOPATH`.

This doesn't actually remove `AUTO_GOPATH`, people can still use it.

Signed-off-by: Brian Goff <[email protected]>
@cpuguy83 cpuguy83 force-pushed the autogo_to_the_future branch from 9270df6 to ce37cb3 Compare January 2, 2025 19:38
Copy link
Copy Markdown
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@thaJeztah thaJeztah merged commit 58125b6 into moby:master Jan 2, 2025
@cpuguy83 cpuguy83 deleted the autogo_to_the_future branch January 2, 2025 23:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/project kind/enhancement Enhancements are not bugs or new features but can improve usability or performance. status/2-code-review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants