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 — Caching should use go.mod, not go.sum · Issue #478 · actions/setup-go

Caching should use go.mod, not go.sum #478

New issue
Copy link
New issue
Copy link
Closed
#705
Closed
Caching should use go.mod, not go.sum#478
#705
Copy link
Assignees
v-priyagupta108
Labels
feature requestNew feature or request to improve the current logic

Description

@peterbourgon
peterbourgon
opened on May 9, 2024
Issue body actions

go.sum is an append-only log of checksums, used to verify the integrity of modules downloaded during builds. It's essentially a manifest file (shasums) and not any kind of lock file (Cargo.lock). It doesn't represent the dependencies of the corresponding module in any meaningful sense. This dependabot issue goes into more detail.

Cache keys for Go modules need to be based on the (normalized) content of go.mod, not go.sum, in order to be useful.

Reacted by Alexey Palazhchenko, enzzc, Tamir Duberstein, Olivier Boukili, Kishan B, Stano Bocinec, Ben Wakeford, Matthew Rothenberg, Alexandru Ungur, Alex and 5 more
Reacted by mrclmr, Melroy van den Berg and Alexandru Ungur

Activity

Next
  1. peterbourgon
    added
    bugSomething isn't working
    needs triage
    on May 9, 2024
  2. v-aparnajyothi-y
    removed
    needs triage
    on May 10, 2024
  3. v-aparnajyothi-y commented on May 10, 2024

    @v-aparnajyothi-y
    v-aparnajyothi-y
    on May 10, 2024
    Contributor
    More actions

    Hello @peterbourgon, Thank you for creating this issue and we will look into it :)

  4. v-aparnajyothi-y
    self-assigned this
    on Jun 4, 2024
  5. matthewhughes934 commented on Jun 4, 2024

    @matthewhughes934
    matthewhughes934
    on Jun 4, 2024
    Contributor
    More actions

    go.sum is an append-only log of checksums

    Note: go.sum will be pruned as dependencies are removed if you run go mod tidy (from: https://go.dev/ref/mod#go-sum-files):

    go mod tidy will add missing hashes and will remove unnecessary hashes from go.sum.

    used to verify the integrity of modules downloaded during builds

    Is this not a suitable for a file to be used as a cache key? if some new file needs to be downloaded that the cache should be updated to include that new file.

  6. peterbourgon commented on Jun 7, 2024

    @peterbourgon
    peterbourgon
    on Jun 7, 2024
    Author
    More actions

    Is this not a suitable for a file to be used as a cache key? if some new file needs to be downloaded that the cache should be updated to include that new file.

    Unfortunately not, no.

    Again, go.sum isn't a lock file, and doesn't (necessarily) represent the actual dependencies used by the module. In fact, it doesn't even need to be committed! It exists purely to verify any dependencies fetched as part of the build process.

    The go.sum file contains cryptographic hashes of the module’s direct and indirect dependencies ... The go.sum file may contain hashes for multiple versions of a module. The go command may need to load go.mod files from multiple versions of a dependency in order to perform minimal version selection. go.sum may also contain hashes for module versions that aren’t needed anymore.

    Just use go.mod and the problem is solved.

    And don't take my word for it: github.blog, etc.

    Reacted by Alexandru Ungur and Amit Kaplan
  7. lukaszcl
    added 2 commits that reference this issue on Aug 14, 2024

    Update caching in setup-go GHA

    bba4be1

    Update chainlink-testing-framework/setup-go and chainlink-testing-fra…

    0ce1e67
  8. v-aparnajyothi-y commented on Aug 22, 2024

    @v-aparnajyothi-y
    v-aparnajyothi-y
    on Aug 22, 2024
    Contributor
    More actions

    Hello @peterbourgon,

    Thank you once again for creating this issue. We have analyzed using go.mod instead of go.sum for caching and identified the following key points:

    • The go.mod file declares a project's dependencies. Any changes here represent changes to the project's dependencies, necessitating a cache update.
    • The go.sum file logs all downloaded modules and includes checksums for integrity verification but doesn't represent the actual dependencies used by the project.

    We will check the feasibility of the requested implementation and consider it as a feature request once we receive some feedback.

    Reacted by Peter Bourgon, Rémy Léone, Kishan B, Taras, Bojun Kim, Margarita Gonzalez Huitron and Amit Kaplan
  9. v-aparnajyothi-y
    added
    feature requestNew feature or request to improve the current logic
    and removed
    bugSomething isn't working
    on Aug 22, 2024
  10. v-aparnajyothi-y
    removed their assignment
    on Aug 22, 2024
  11. peterbourgon commented on Aug 22, 2024

    @peterbourgon
    peterbourgon
    on Aug 22, 2024
    Author
    More actions

    Thank you!

  12. xeger commented on Sep 9, 2024

    @xeger
    xeger
    on Sep 9, 2024
    More actions

    The caching performed by actions/setup-go is ineffective at caching gocache and gomodcache contents with my project and this may be one contributing factor. I stress that I don't know this for sure.

    All I know is that when I cache the gocache directory myself using actions/cache, I benefit from significantly faster build, test and lint performance.

    I do see evidence that setup-go is effectively caching some or all of gomodcache, so it seems my issue is mostly limited to gocache contents (which govern the behavior of go install, golangci-lint and go test).

    Reacted by Rémy Léone and Brad Clark
  13. 3 remaining items

  14. fingon commented on Feb 16, 2025

    @fingon
    fingon
    on Feb 16, 2025
    More actions

    If you include go mod tidy and linting for its use, using go.sum (alongside go.mod) is better than just go.mod. The earlier linked blogpost just refers to case where tidy is not used and they care about really used mod versions.

    If upstream or someone/something changes binary in cache without changing version, you will not see that without using also sum file in git.

    Assuming you have both in git, and sum is tidied, then it becomes question if you want to support sum changing without mod changing. If so, you should use sum as cache key. Otherwise mod.

  15. v-priyagupta108
    self-assigned this
    on Dec 3, 2025
  16. AlekSi commented on Dec 5, 2025

    @AlekSi
    AlekSi
    on Dec 5, 2025
    More actions

    Among other things, go.mod includes Go language and toolchain versions. It should be used instead of go.sum, which, as mentioned above, does not even need to be committed.

  17. fingon commented on Dec 5, 2025

    @fingon
    fingon
    on Dec 5, 2025
    More actions

    If you do not commit go sum, you will not have consistent builds OR verifiable builds.

    Correct answer is always to use both, as if one or the other changes, environment should be different than what it was.

  18. AlekSi commented on Dec 5, 2025

    @AlekSi
    AlekSi
    on Dec 5, 2025
    More actions

    If you do not commit go sum, you will not have consistent builds OR verifiable builds.

    I’m sorry, but that's simply incorrect. The set of dependencies is defined by the go.mod file, not go.sum. Checksums in most cases are verified by https://sum.golang.org or a compatible service. All that was described above.

    Reacted by Benjamin PATRON
  19. fingon commented on Dec 5, 2025

    @fingon
    fingon
    on Dec 5, 2025
    More actions

    If you do not commit go sum, you will not have consistent builds OR verifiable builds.

    I’m sorry, but that's simply incorrect. The set of dependencies is defined by the go.mod file, not go.sum. Checksums in most cases are verified by https://sum.golang.org or a compatible service. All that was described above.

    That is simply untrue in the general case. If someone republishes e.g. version 1.0 of a package (with different hash), go.mod happily refers to it, and depending on when you run the go build (and what is in your local mod cache), you will either use old 1.0 or new 1.0.

    This exactly what go.sum is added for to protect against (it stores the hash of what v1.0 really means at the time someone added it, as opposed to what is found later).

    go.mod defines logical version dependencies (transitively), go.sum specifies exact versions of those dependencies used in the build to be consistent. (with the time they were added, and until forever)

    If you think I am 'wrong', please describe how consistent reproducible builds work without go.sum.

  20. AlekSi commented on Dec 5, 2025

    @AlekSi
    AlekSi
    on Dec 5, 2025
    More actions

    I already mentioned https://sum.golang.org in my previous comment, which you ignored. Please check it out.

    and depending on when you run the go build (and what is in your local mod cache), you will either use old 1.0 or new 1.0.

    The checksum is checked against https://sum.golang.org on module download and on go mod verify.

  21. fingon commented on Dec 5, 2025

    @fingon
    fingon
    on Dec 5, 2025
    More actions

    and depending on when you run the go build (and what is in your local mod cache), you will either use old 1.0 or new 1.0.

    The checksum is checked against https://sum.golang.org on module download and on go mod verify.

    How does it work for private repositories?

    Even for public repositories, there is also no guarantee that the moment the hash was fetched and stored by Google was the first time module was really available with the same tag, leading to potential mod cache inconsistencies between nodes.

    Finally, not everyone uses Google service as go.sum contains the relevant bits and covers the 2 above things Google does not. (it is build option, not requirement, currently - and any network access slows you down.)

  22. v-priyagupta108 commented on Dec 12, 2025

    @v-priyagupta108
    v-priyagupta108
    on Dec 12, 2025
    Contributor
    More actions

    Thank you to everyone for your input and discussion on this request.

    We have decided to update the action caching strategy to use go.mod as the cache key. This approach accurately tracks the project's dependencies and versions, helps avoid unnecessary cache refreshes, and improves CI performance. Our aim is to enhance efficiency and reliability for most workflows.

    For teams with stricter requirements that wish to use go.sum, it can be included by setting the cache-dependency-path input, or by leveraging actions/cache for advanced caching options.

    Thank you again for your contributions.

    Reacted by Alexey Palazhchenko, Gaiaz Iusipov, Benjamin PATRON and Patryk Małek
  23. AlekSi commented on Jan 5, 2026

    @AlekSi
    AlekSi
    on Jan 5, 2026
    More actions

    https://words.filippo.io/gosum/

    Reacted by Kishan B
  24. v-priyagupta108
    linked a pull request that will close this issueUpdate default Go module caching to use go.mod #705on Jan 13, 2026
  25. v-priyagupta108 commented on Jan 14, 2026

    @v-priyagupta108
    v-priyagupta108
    on Jan 14, 2026
    Contributor
    More actions

    Hi everyone,

    We’ve opened PR #705, which updates the action’s default caching behavior to use go.mod. We hope this enhancement improves caching accuracy and benefits your workflow. We’d greatly appreciate your feedback and review on this change.

    If you experience any unexpected issues, please let us know.

    Thank you in advance!

    Reacted by Kishan B and Alexey Palazhchenko
  26. v-HarithaVattikuti
    closed this as completedin #705on Jan 26, 2026
  27. alnr
    added a commit that references this issue on Feb 16, 2026

    chore: update README to reference go.mod instead of go.sum

    797a118
  28. Jeppeys
    added a commit that references this issue on Apr 15, 2026

    Update setup-go and checkout

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

Metadata

Metadata

Assignees

  • @v-priyagupta108
    v-priyagupta108

Labels

feature requestNew feature or request to improve the current logic

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    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.