golang-microservices icon indicating copy to clipboard operation
golang-microservices copied to clipboard

Build Fails Due to Dependency Version Mismatch

Open deer8888 opened this issue 1 week ago • 1 comments

Description

While rebuilding the project using the latest version of Go, with Go's official recommendation to use gomodule for initialization and building, we found that the build process fails due to mismatched module path.

The following error log was produced during the build process:

......
go: found github.com/stretchr/testify/assert in github.com/stretchr/testify v1.9.0
go: github.com/federicoleon/golang-microservices/src/api/log/option_a imports
        github.com/Sirupsen/logrus: github.com/Sirupsen/[email protected]: parsing go.mod:
        module declares its path as: github.com/sirupsen/logrus
                but was required as: github.com/Sirupsen/logrus

Result

The build fails with errors related to mismatched module path.

The error dependency is github.com/Sirupsen/logrus.

Reason

The error log suggests module path declaration github.com/sirupsen/logrus in go.mod, which is inconsistent with import path github.com/Sirupsen/logrus .

Proposed Solution

To resolve this issue, we analyzed the project and identified the correct versions of the required dependencies.

The analysis shows that the correct declaration for the dependency is replace github.com/Sirupsen/logrus => github.com/sirupsen/logrus v0.11.2.

Consider adopting this suggested version to prevent other developers from encountering build failures when constructing the project.

This information can be documented in the README.md file or another relevant location.

Additional Suggestions

To ensure reproducible builds and align with the evolving trends of the Go programming language, it is recommended that the current project be migrated to the Go module mechanism.

Updating to the go module mechanism allows for managing third-party dependency versions through the go.mod file, which provides a centralized and consistent way to specify dependency constraints.

We have generated a go.mod file with the correct versions of the third-party dependencies needed for this project.

The suggested go.mod file is as follows:


require github.com/stretchr/testify v1.9.1-0.20241003162259-5dc934f9aa22

require (
	github.com/Sirupsen/logrus v0.0.0-00010101000000-000000000000
	github.com/gin-gonic/gin v1.10.0
	github.com/pmezard/go-difflib v1.0.1-0.20181226105215-1ef1646f464b // indirect
	go.uber.org/zap v1.27.0
)

require (
	github.com/bytedance/sonic v1.11.6 // indirect
	github.com/bytedance/sonic/loader v0.1.1 // indirect
	github.com/cloudwego/base64x v0.1.4 // indirect
	github.com/cloudwego/iasm v0.2.0 // indirect
	github.com/davecgh/go-spew v1.1.1 // indirect
	github.com/gabriel-vasile/mimetype v1.4.3 // indirect
	github.com/gin-contrib/sse v0.1.0 // indirect
	github.com/go-playground/locales v0.14.1 // indirect
	github.com/go-playground/universal-translator v0.18.1 // indirect
	github.com/go-playground/validator/v10 v10.20.0 // indirect
	github.com/goccy/go-json v0.10.2 // indirect
	github.com/json-iterator/go v1.1.12 // indirect
	github.com/klauspost/cpuid/v2 v2.2.7 // indirect
	github.com/leodido/go-urn v1.4.0 // indirect
	github.com/mattn/go-isatty v0.0.20 // indirect
	github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
	github.com/modern-go/reflect2 v1.0.2 // indirect
	github.com/pelletier/go-toml/v2 v2.2.2 // indirect
	github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
	github.com/ugorji/go/codec v1.2.12 // indirect
	go.uber.org/multierr v1.10.0 // indirect
	golang.org/x/arch v0.8.0 // indirect
	golang.org/x/crypto v0.23.0 // indirect
	golang.org/x/net v0.25.0 // indirect
	golang.org/x/sys v0.20.0 // indirect
	golang.org/x/text v0.15.0 // indirect
	google.golang.org/protobuf v1.34.1 // indirect
	gopkg.in/yaml.v3 v3.0.1 // indirect
)

replace github.com/Sirupsen/logrus => github.com/sirupsen/logrus v0.11.2

Additional Information:

This issue was identified as part of our research project focused on automating the analysis of GOPATH projects to provide accurate dependency versions for seamless migration to Go Modules. We value your feedback and would appreciate any comments or suggestions regarding this approach.

deer8888 avatar Feb 22 '25 08:02 deer8888