-
-
Notifications
You must be signed in to change notification settings - Fork 23
Description
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/spf13/cobra in github.com/spf13/cobra v1.8.1
go: found github.com/spf13/viper in github.com/spf13/viper v1.19.0
go: github.com/sapk/docker-volume-gluster/common imports
github.com/Sirupsen/logrus: github.com/Sirupsen/logrus@v1.9.3: 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 v1.4.1
.
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/spf13/viper v1.6.2
replace github.com/cpuguy83/go-md2man => github.com/cpuguy83/go-md2man/v2 v2.0.3
require github.com/docker/go-plugins-helpers v0.0.0-20211224144127-6eecb7beb651
require github.com/spf13/cast v1.6.0 // indirect
require github.com/spf13/pflag v1.0.6-0.20210604193023-d5e0c0615ace // indirect
require github.com/pelletier/go-toml v1.9.5 // indirect
require github.com/mitchellh/mapstructure v1.5.1-0.20231216201459-8508981c8b6c // indirect
replace github.com/coreos/go-systemd => github.com/coreos/go-systemd/v22 v22.5.1-0.20231103132048-7d375ecc2b09
require github.com/fsnotify/fsnotify v1.7.1-0.20240515161322-ad7424447bfe // indirect
require github.com/docker/go-connections v0.5.0 // indirect
require github.com/subosito/gotenv v1.6.0 // indirect
require github.com/spf13/jwalterweatherman v1.1.1-0.20230519081920-87ef77d773dc // indirect
require github.com/stretchr/testify v1.10.0 // indirect
replace github.com/Sirupsen/logrus => github.com/sirupsen/logrus v1.4.1
require github.com/inconshreveable/mousetrap v1.1.0 // indirect
require github.com/spf13/afero v1.11.0 // indirect
require github.com/konsorten/go-windows-terminal-sequences v1.0.3 // indirect
require github.com/magiconair/properties v1.8.7 // indirect
require github.com/Microsoft/go-winio v0.5.3 // indirect
require (
github.com/Sirupsen/logrus v0.0.0-00010101000000-000000000000
github.com/spf13/cobra v0.0.7
)
require (
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
golang.org/x/sys v0.27.0 // indirect
golang.org/x/text v0.20.0 // indirect
gopkg.in/ini.v1 v1.51.0 // indirect
gopkg.in/yaml.v2 v2.2.4 // indirect
)
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.