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

Update go mod version before running go mod tidy -e #11815

Merged
merged 4 commits into from
Mar 14, 2025

Conversation

thavaahariharangit
Copy link
Contributor

@thavaahariharangit thavaahariharangit commented Mar 14, 2025

What are you trying to accomplish?

The issue arises when running go mod tidy -e on Go version 1.20.10, as it fails with the following error:

dependabot@066ceb51a4d3:~/dependabot-updater/repo$ go mod tidy -e
go: errors parsing go.mod:
/home/dependabot/dependabot-updater/repo/go.mod:3: invalid go version '1.23.0': must match format 1.23
/home/dependabot/dependabot-updater/repo/go.mod:5: unknown directive: toolchain
dependabot@066ceb51a4d3:~/dependabot-updater/repo$ go version
go version go1.20.10 linux/arm64
dependabot@066ceb51a4d3:~/dependabot-updater/repo$

To resolve this, update the go.mod file to the format go 1.20 and remove the toolchain directive before running go mod tidy -e:

Next, modify the go.mod file with:

sed -i 's/go 1.23.0/go 1.23/' go.mod
sed -i '/toolchain/d' go.mod

After that, running go mod tidy -e should work as expected, but it still shows a version mismatch:

dependabot@066ceb51a4d3:~/dependabot-updater/repo$ go mod tidy -e
go: go.mod file indicates go 1.23, but maximum version supported by tidy is 1.20
go: downloading github.com/sirupsen/logrus v1.9.3
go: downloading github.com/bradleyfalzon/ghinstallation/v2 v2.14.0
go: downloading github.com/cenkalti/backoff/v4 v4.3.0
go: downloading github.com/google/go-github/v62 v62.0.0
go: downloading golang.org/x/tools v0.29.0
...

Anything you want to highlight for special attention from reviewers?

This PR automates the above steps to ensure the process is handled correctly.

Example:

2025/03/14 14:52:13 INFO Running: sed -i 's/go 1.23.0/go 1.23/' go.mod
2025/03/14 14:52:13 INFO Running: sed -i '/toolchain/d' go.mod
2025/03/14 14:52:13 INFO `go mod tidy` succeeded

How will you know you've accomplished your goal?

Checklist

  • I have run the complete test suite to ensure all tests and linters pass.
  • I have thoroughly tested my code changes to ensure they work as expected, including adding additional tests for new functionality.
  • I have written clear and descriptive commit messages.
  • I have provided a detailed description of the changes in the pull request, including the problem it addresses, how it fixes the problem, and any relevant details about the implementation.
  • I have ensured that the code is well-documented and easy to understand.

@thavaahariharangit thavaahariharangit requested a review from a team as a code owner March 14, 2025 15:12
@github-actions github-actions bot added the L: go:modules Golang modules label Mar 14, 2025
@thavaahariharangit thavaahariharangit merged commit 07cce3f into main Mar 14, 2025
74 checks passed
@thavaahariharangit thavaahariharangit deleted the harry/update-go-mod-version branch March 14, 2025 16:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
L: go:modules Golang modules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants