Should I Commit the go.sum File to the Repo?
TL;DR Yes, probably.
Using Go Modules, you will have both a
go.mod and a
go.sum file within your coding repository. A question often asked is whether you should commit the sum portion of the file as it’s automatically generated. These files help manage the dependencies of your project and they differ by the
go.mod file being human-friendly, listing the libraries used within the project, and the
go.sum listing the very specific vendor versions of each dependency (not just your direct ones, but also the whole tree).
By committing the sum file then you can share with fellow developers (or cloud platforms) the exact same versions that you used to build it. All this helps keep
bugs un-intendended side effects to a minimum.
The down-side of doing this though is that you can encounter merge conflicts when the file is changed as git (if you’re using git?) is not always the best on automatically generated files like these - as keys will be different.