Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the GO111MODULE=off env var from go list #415

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jamestoyer
Copy link

@jamestoyer jamestoyer commented Oct 24, 2023

Before this PR

When running ./godelw artifacts build or ./godelw products in golang 1.21 there is an edge case that causes the underlying go list command to fail.

If you have a repo that has a main.go file in the root of the repo and then subsequent sub packages with a main.go the afore mentioned commands fail to run. Or more specifically, go list fails to run. I've tracked it down to GO111MODULE=off being hardcoded as an environment variable in the runGoList function.

I've validated this by running go list -f "{{.Name}} {{.ImportPath}}" "./..." from the root of the affected repo and then GO111MODULE=off go list -f "{{.Name}} {{.ImportPath}}" "./...". The former works and the latter fails with the same error as distgo.

The error, heavily truncated, is as follows

failed to determine paths to main packages in /root/project: command [go list -f {{.Name}} {{.ImportPath}} ./...] run in directory /root/project failed with outputBytes "main.go:6:2: cannot find package \"github.com/palantir/witchcraft-go-logging/wlog-zap\" in any of:
	/local/go-dists/go1.21.3/src/github.com/palantir/witchcraft-go-logging/wlog-zap (from $GOROOT)
	/home/go/src/github.com/palantir/witchcraft-go-logging/wlog-zap (from $GOPATH)

It appears for whatever reason that in Go 1.21 the behaviour has changed.

After this PR

This PR removes GO111MODULE=off so that distgo can work once again with the style of repos mentioned earlier.
==COMMIT_MSG==
Remove the GO111MODULE=off env var from go list
==COMMIT_MSG==

Possible downsides?

It is possible go list will now not find all the modules in a repo and thus cause inconsistencies with the current behaviour.


This change is Reviewable

When running `./godelw artifacts build` or `./godelw products` in golang 1.21 there is an edge case that causes the underlying `go list` command to fail. 

If you have a repo that has a `main.go` file in the root of the repo and then subsequent sub packages with a main.go the afore mentioned commands fail to run. Or more specifically, `go list` fails to run. I've tracked it down to `GO111MODULE=off` being hardcoded as an environment variable in the `runGoList` function.

 I've validated this by running `go list -f "{{.Name}} {{.ImportPath}}" "./..."` from the root of the affected repo and then `GO111MODULE=off go list -f "{{.Name}} {{.ImportPath}}" "./..."`. The former works and the latter fails with the same error as distgo.

The error, heavily truncated, is as follows

```
failed to determine paths to main packages in /root/project: command [go list -f {{.Name}} {{.ImportPath}} ./...] run in directory /root/project failed with outputBytes "main.go:6:2: cannot find package \"github.com/palantir/witchcraft-go-logging/wlog-zap\" in any of:
	/local/go-dists/go1.21.3/src/github.com/palantir/witchcraft-go-logging/wlog-zap (from $GOROOT)
	/home/go/src/github.com/palantir/witchcraft-go-logging/wlog-zap (from $GOPATH)```

It appears for whatever reason that in Go 1.21 the behaviour has changed. This PR removes `GO111MODULE=off` so that distgo can work once again with the style of repos mentioned earlier.
@changelog-app
Copy link

changelog-app bot commented Oct 24, 2023

Generate changelog in changelog/@unreleased

What do the change types mean?
  • feature: A new feature of the service.
  • improvement: An incremental improvement in the functionality or operation of the service.
  • fix: Remedies the incorrect behaviour of a component of the service in a backwards-compatible way.
  • break: Has the potential to break consumers of this service's API, inclusive of both Palantir services
    and external consumers of the service's API (e.g. customer-written software or integrations).
  • deprecation: Advertises the intention to remove service functionality without any change to the
    operation of the service itself.
  • manualTask: Requires the possibility of manual intervention (running a script, eyeballing configuration,
    performing database surgery, ...) at the time of upgrade for it to succeed.
  • migration: A fully automatic upgrade migration task with no engineer input required.

Note: only one type should be chosen.

How are new versions calculated?
  • ❗The break and manual task changelog types will result in a major release!
  • 🐛 The fix changelog type will result in a minor release in most cases, and a patch release version for patch branches. This behaviour is configurable in autorelease.
  • ✨ All others will result in a minor version release.

Type

  • Feature
  • Improvement
  • Fix
  • Break
  • Deprecation
  • Manual task
  • Migration

Description

Remove the GO111MODULE=off env var from go list

Check the box to generate changelog(s)

  • Generate changelog entry

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant