Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Go modules: checksum mismatch

Tags:

go

go-modules

I recently started using modules in Go, but I frequently encounter issues where everything works fine on one machine, but a checksum mismatch is encountered when building the codebase on another machine.

The issue always concerns the same third party dependency (github.com/ericlagergren/decimal):

go: verifying github.com/ericlagergren/[email protected]: checksum mismatch
    downloaded: h1:HQGCJNlqt1dUs/BhtEKmqWd6LWS+DWYVxi9+Jo4r0jE=
    go.sum:     h1:x4oNpFLLl+8l+iLgksNHzZewTS0SKp6m0hlLwzXRbqA=

I've tried various things: removing & regenerating go.sum, upgrading Go itself to the latest patch version and removing the dependency from go.mod but nothing seems to fix this issue.

Does anyone have an idea how to fix this issue?

like image 320
edwardmp Avatar asked Jan 10 '19 17:01

edwardmp


People also ask

How to fix go checksum mismatch?

If you encounter a checksum mismatch error, delete go. sum, execute go clean -modcache , and then execute go mod download . That's what I did, and after that, no more errors were reported. When I commit the new go.

What can cause a checksum mismatch?

A checksum mismatch is what happens when a file on the client and on the server are not identical. When players get this error it can be for various reasons, but most commonly they are: A recent Assetto Corsa update has not been applied to either the client or server.

What is go sum file?

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 (for example, after an upgrade).


1 Answers

You can run go clean -modcache and then go mod tidy which will re-download all deps with the correct checksum (this updates the pkg cache in $GOPATH/pkg/mod/).

To update vendor/ folder run: go mod vendor.

like image 84
Alex Efimov Avatar answered Sep 22 '22 17:09

Alex Efimov