Go modules: checksum mismatch

后端 未结 5 2584
深忆病人
深忆病人 2021-02-19 21:41

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 co

5条回答
  •  一个人的身影
    2021-02-19 22:25

    You need to delete your package from the go.sum file. If you run from terminal mode, using CI/CD or Dockerfile you can use that sh command:

    sed '/^github.com\/ericlagergren\/decimal@/d' ./go.sum > temp.txt && mv temp.txt go.sum
    

    Which does:

    • sed - unix application
    • '/^ - starts line from
    • github.com\/hyperledger\/fabric v1.4.4 - your package name (actually RegEX line, shield / with \)
    • /d' - means delete line
    • go.sum - our golang sum file
    • > temp.txt - save output to temporary file
    • mv temp.txt go.sum - rewrite our go.sum with temporary file

    P.S.: go mod tidy - only removes unused packages and add new versions. But it doesn`t delete olders.

提交回复
热议问题