-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
cmd/go: add documentation for go.work.sum #51941
Comments
CC @matloob |
I recently added go.work to a large project and another maintainer asked me about the sum file and it left me a bit clueless as well. Seems oddly missing from https://go.dev/ref/mod#workspaces |
I agree, a little piece of documentation on the purpose of this file and its insides would be great. |
I also came across a few situations where the |
I've been really struggling with this myself. My |
Change https://go.dev/cl/563855 mentions this issue: |
I sent out CL 563855 to add documentation to golang.org/ref/mod, which seems to be the best place for it. @calebschoepp Usually go.work files shouldn't be checked in, so go.work.sum files shouldn't be checked in either. But if you are checking in your go.work file it makes sense to check in the go.work.sum file for consistency for the same reason that a go.sum is checked in: to guarantee that others doing a build in your repo are getting the same results. Maybe we could add a line about that to the text proposed for 53502. |
I'd like to propose that we remove `go.work.sum` from version control. I'd say in general going to workspaces has improved 95%+ of workflows, but there are a couple annoying sharp edges. The main noticeable one is that on any new release versions in `go.work.sum` get updated, forcing the change to be checked in with a separate PR. Reading more about `go.work.sum`, I found that the Go developers didn't even bother to document it for two full years, only doing so reluctantly earlier this year [1]. Its purpose is to track dependencies that are used in the workspace but not part of any normal modules [2]: > The go command will maintain a go.work.sum file that keeps track of > hashes used by the workspace that are not in collective workspace > modules’ go.sum files. In River, only the modules, not the workspace, are public entities used in other projects, and all of their builds are fully reproducible because they all have `go.sum`. `go.work.sum` tracks some extra stuff, but I don't think any of it is crucial to what River's users are actually working with. Furthermore, I learned that the Go docs actually recommend not checking in `go.work` in many cases: > It is generally inadvisable to commit go.work files into version control systems, for two reasons: > > * A checked-in go.work file might override a developer’s own go.work > file from a parent directory, causing confusion when their use > directives don’t apply. > > * A checked-in go.work file may cause a continuous integration (CI) > system to select and thus test the wrong versions of a module’s > dependencies. CI systems should generally not be allowed to use the > go.work file so that they can test the behavior of the module as it > would be used when required by other modules, where a go.work file > within the module has no effect. > > That said, there are some cases where committing a go.work file makes > sense. For example, when the modules in a repository are developed > exclusively with each other but not together with external modules, > there may not be a reason the developer would want to use a different > combination of modules in a workspace. In that case, the module author > should ensure the individual modules are tested and released properly. I think the last paragraph applies more to River -- it's a clear UX improvement and we're all working in a fairly consistent environment without using any other external modules, but even so, if it's often safe that a `go.work` could be omitted, I think there's a good argument that `go.work.sum` could be omitted too. I tried this in a branch and `go get`ing River from another test project, and the removal of `go.work.sum` doesn't seem to have any negative effect. I'd like to propose that we try removing it from Git for a while and just see if there are any noticeable problems. I don't think there will be, and this will purely be beneficial as it lets us avoid needing to bump the file on every release, but we can always add it back in case that turns out to be wrong. [1] golang/go#51941 [2] https://go.dev/ref/mod#workspaces
I'd like to propose that we remove `go.work.sum` from version control. I'd say in general going to workspaces has improved 95%+ of workflows, but there are a couple annoying sharp edges. The main noticeable one is that on any new release versions in `go.work.sum` get updated, forcing the change to be checked in with a separate PR. Reading more about `go.work.sum`, I found that the Go developers didn't even bother to document it for two full years, only doing so reluctantly earlier this year [1]. Its purpose is to track dependencies that are used in the workspace but not part of any normal modules [2]: > The go command will maintain a go.work.sum file that keeps track of > hashes used by the workspace that are not in collective workspace > modules’ go.sum files. In River, only the modules, not the workspace, are public entities used in other projects, and all of their builds are fully reproducible because they all have `go.sum`. `go.work.sum` tracks some extra stuff, but I don't think any of it is crucial to what River's users are actually working with. Furthermore, I learned that the Go docs actually recommend not checking in `go.work` in many cases: > It is generally inadvisable to commit go.work files into version control systems, for two reasons: > > * A checked-in go.work file might override a developer’s own go.work > file from a parent directory, causing confusion when their use > directives don’t apply. > > * A checked-in go.work file may cause a continuous integration (CI) > system to select and thus test the wrong versions of a module’s > dependencies. CI systems should generally not be allowed to use the > go.work file so that they can test the behavior of the module as it > would be used when required by other modules, where a go.work file > within the module has no effect. > > That said, there are some cases where committing a go.work file makes > sense. For example, when the modules in a repository are developed > exclusively with each other but not together with external modules, > there may not be a reason the developer would want to use a different > combination of modules in a workspace. In that case, the module author > should ensure the individual modules are tested and released properly. I think the last paragraph applies more to River -- it's a clear UX improvement and we're all working in a fairly consistent environment without using any other external modules, but even so, if it's often safe that a `go.work` could be omitted, I think there's a good argument that `go.work.sum` could be omitted too. I tried this in a branch and `go get`ing River from another test project, and the removal of `go.work.sum` doesn't seem to have any negative effect. I'd like to propose that we try removing it from Git for a while and just see if there are any noticeable problems. I don't think there will be, and this will purely be beneficial as it lets us avoid needing to bump the file on every release, but we can always add it back in case that turns out to be wrong. [1] golang/go#51941 [2] https://go.dev/ref/mod#workspaces
With the release of Go 1.18, we now have workspaces. From my findings, workspaces appear to be documented in the following locations:
None of these locations however make mention of the
go.work.sum
file. Thego.work.sum
file was however described in the proposal.This issue is to bring the description of the
go.work.sum
file from the proposal into the official documentation.The text was updated successfully, but these errors were encountered: