GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat: use go.mod when no version inputs specified by raeperd · Pull Request #660 · actions/setup-go

Conversation

@raeperd

@raeperd raeperd commented Oct 12, 2025

Copy link
Copy Markdown

Description:

This PR adds automatic go.mod detection when neither go-version nor go-version-file is specified. This simplifies workflows for Go projects that already have a go.mod file.

Before:

steps:
  - uses: actions/checkout@v5
  - uses: actions/setup-go@v6
    with:
      go-version-file: go.mod
  - run: go version

After:

steps:
  - uses: actions/checkout@v5
  - uses: actions/setup-go@v6
    # Automatically detects and uses go.mod from repository root
  - run: go version

Related issue:
Closes #523

Check list:

  • Mark if documentation changes are required.
  • Mark if tests were added or updated to cover the changes.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
raeperd added 3 commits October 12, 2025 17:56
@raeperd
feat: auto-detect go.mod when no version inputs specified
612cee1
- Add unit tests for auto-detection behavior
- Implement go.mod auto-detection in resolveVersionInput()
- Explicit inputs still take precedence over auto-detection

Related issue: actions#523
@raeperd
test: add E2E test for auto go.mod detection
ec93c40
Related issue: actions#523
@raeperd
docs: document automatic go.mod detection
a16a57d
@raeperd
raeperd requested a review from a team as a code owner October 12, 2025 08:59
@raeperd raeperd changed the title feat: auto-detect go.mod when no version inputs specified feat: use go.mod when no version inputs specified Oct 27, 2025
@raeperd
Merge branch 'main' into feat-go-version-file-by-default
e9ad314
Resolve merge conflicts:
- action.yml: combine auto-detect description with .go-version/.tool-versions support
- versions.yml: keep auto-detect-go-mod job alongside new tool-versions/go-version jobs
- README.md: keep auto-detect section, adopt main's link to advanced-usage docs
- tests: keep auto-detect tests alongside new go-download-base-url tests
@raeperd

raeperd commented Mar 25, 2026

Copy link
Copy Markdown
Author

Hi @aparnajyothi-y @priyagupta108,

As a user of this action, this would be a nice quality-of-life improvement — I find myself specifying go-version-file: go.mod in every workflow even though it's the most common setup.

I saw you both reviewed related changes in #705 and #673, so your feedback here would be really valuable. Happy to make any changes needed.

Thank you!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

raeperd added 2 commits March 26, 2026 02:09
@raeperd
docs: move auto-detect go.mod docs to advanced-usage.md
16c5d19
Follows the pattern from actions#724 where detailed usage docs live in
docs/advanced-usage.md rather than README.md.
@raeperd
Merge branch 'main' into feat-go-version-file-by-default
66a7086
@v-priya-kinthali

v-priya-kinthali commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Hi @raeperd 👋,
Thanks for the PR! We've reviewed it, and based on our analysis the main trade-off with making go.mod the default is backward compatibility, it would be a breaking change for workflows that currently rely on the pre-installed version (they'd silently switch to the go.mod version).

A few related concerns:

  • Behaviour change: some workflows intentionally use pre-installed Go; defaulting to go.mod alters runtime setup and download/cache behaviour unexpectedly.
  • Hidden patch drift: when go.mod only specifies major.minor (e.g. go 1.21), setup-go resolves the latest patch, which can change over time unless the exact patch is pinned.
  • Monorepo ambiguity: defaulting to the root go.mod is wrong for many multi-module repos unless the path is chosen explicitly.
  • Runner drift: GitHub-hosted runners keep updating pre-installed Go and remove EOL versions, so the current fallback isn't static either.

Since the opt-in(go-version-file: go.mod) already exists, could you please share whether you still need this as a default? That'll help us decide the best path forward. Thanks!

raeperd reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@raeperd

raeperd commented Jul 31, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Author

Thanks for the detailed review. Yes, I still think this is a useful and reasonable default.

This PR uses the root go.mod only when neither version input is specified and the file exists. Otherwise, the current pre-installed-version fallback remains unchanged.

Regarding the concerns:

  • Behavior change: This affects only workflows that have a root go.mod but intentionally prefer the runner’s Go version. I believe that is a niche compatibility case rather than a broad breaking change.
  • Patch drift: This already occurs with go-version-file: go.mod. Projects requiring an exact patch can declare one or specify it explicitly.
  • Monorepos: Repositories with only nested go.mod files are unaffected. A different module can be selected explicitly.
  • Runner drift: This supports the change: the pre-installed version also changes, while go.mod provides a repository-controlled version signal.
  • Download/cache: These follow the existing behavior of explicitly using go-version-file: go.mod.

For the common single-module case, using the root go.mod is a reasonable and predictable default with limited compatibility impact.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@v-priya-kinthali

v-priya-kinthali commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Thank you for the detailed response, @raeperd.

Our primary concern remains that changing the default behavior introduces a silent breaking change. Workflows that currently have a root go.mod but do not specify a version input would automatically switch from the pre-installed Go to the version defined in go.mod. Given how widely this action is used, even a seemingly niche scenario can translate into a significant number of affected workflows.

We'd also like to highlight that while the patch drift and download/cache behaviors are consistent with go-version-file: go.mod, that path is an explicit, user-initiated choice. Making it the default applies the same behaviour to users who never opted in, which reduces predictability. Similarly, in monorepo setups, defaulting to the root go.mod may unintentionally resolve to the wrong module's version.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@raeperd

raeperd commented Aug 5, 2026

Copy link
Copy Markdown
Author

@priya-kinthali Thanks, that makes sense.

Since the primary concern is backward compatibility rather than the proposed behavior itself, would you be open to considering this change for the next major release? The new default could then be clearly communicated in the release notes and migration guidance.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@coderabbitai coderabbitai Bot mentioned this pull request Aug 11, 2026
feat: utility to verify sync behaviour correctness argoproj-labs/argocd-agent#1066
Merged
1 task done
@v-priya-kinthali

v-priya-kinthali commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Thanks for the detailed responses here, @raeperd.

Building on the cons already highlighted in the thread, there are a few additional concerns worth noting:

  1. The go directive is a minimum, not a pin. go 1.21 resolves to the latest matching patch, and the existing toolchain/GOTOOLCHAIN logic means the resolved version isn't always obvious to the user.

  2. Ambiguity with multiple version files. A repo could contain go.mod, go.work, .tool-versions, and .go-version. Choosing a default precedence is a policy decision that could surprise users.

  3. Weak cost/benefit. The request only saves one line of boilerplate. A breaking change to save a single line isn't a great trade-off, especially when a well-supported opt-in already covers this use case.

The pros are real, while the cons are mostly about risk and surprise. Given that, we'll hold this change for now rather than merge it into the current version. We're open to revisiting it for a future major release, and community interest and feedback on this PR will help us gauge whether to prioritize it then.

Thanks again for the contribution and the thoughtful discussion here.

raeperd reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Make go-version-file: go.mod the default

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@raeperd @v-priya-kinthali
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.