gostudy
gostudy copied to clipboard
Build Fails Due to Dependency Version Mismatch
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/pingguoxueyuan/gostudy/mercury/common in github.com/pingguoxueyuan/gostudy v0.0.0-20191222105913-9e3f839c618f
go: found github.com/pingguoxueyuan/gostudy/mercury/session in github.com/pingguoxueyuan/gostudy v0.0.0-20191222105913-9e3f839c618f
go: github.com/goflyfox/gostudy/listen41/kafka imports
github.com/Shopify/sarama: github.com/Shopify/[email protected]: parsing go.mod:
module declares its path as: github.com/IBM/sarama
but was required as: github.com/Shopify/sarama
Result
The build fails with errors related to mismatched module path.
The error dependency is github.com/Shopify/sarama
.
Reason
The error log suggests module path declaration github.com/IBM/sarama
in go.mod, which is inconsistent with import path github.com/Shopify/sarama
.
Proposed Solution
Solution 1
To resolve this issue, we analyzed the project and identified the correct versions of the required dependencies.
The analysis shows that the correct version for the dependency github.com/Shopify/sarama
is v1.30.0. This version has correct module path declaration.
Consider adopting this suggested version to prevent other developers from encountering build failures when constructing the project.
Solution 2
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/Shopify/sarama => github.com/IBM/sarama v1.43.3
. This version is the latest version of the dependency.
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/Shopify/sarama v1.30.0
require (
github.com/DeanThompson/ginpprof v0.0.0-20201112072838-007b1e56b2e1
github.com/coreos/etcd v2.3.0-alpha.1+incompatible
github.com/garyburd/redigo v1.6.4
github.com/gin-gonic/gin v1.10.0
github.com/go-sql-driver/mysql v1.9.0
github.com/golang/protobuf v1.5.4
github.com/jmoiron/sqlx v1.4.0
github.com/nsqio/go-nsq v1.1.0
github.com/satori/go.uuid v1.2.0
github.com/sony/sonyflake v1.2.0
github.com/urfave/cli v1.22.16
github.com/vmihailenco/msgpack v4.0.4+incompatible
gopkg.in/olivere/elastic.v2 v2.0.61
)
require (
filippo.io/edwards25519 v1.1.0 // indirect
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/cpuguy83/go-md2man/v2 v2.0.5 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/eapache/go-resiliency v1.7.0 // indirect
github.com/eapache/go-xerial-snappy v0.0.0-20230731223053-c322873962e3 // indirect
github.com/eapache/queue v1.1.0 // 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/gogo/protobuf v1.3.2 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/hashicorp/go-uuid v1.0.3 // indirect
github.com/jcmturner/aescts/v2 v2.0.0 // indirect
github.com/jcmturner/dnsutils/v2 v2.0.0 // indirect
github.com/jcmturner/gofork v1.7.6 // indirect
github.com/jcmturner/gokrb5/v8 v8.4.4 // indirect
github.com/jcmturner/rpc/v2 v2.0.3 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.17.9 // indirect
github.com/klauspost/cpuid/v2 v2.2.7 // indirect
github.com/kr/pretty v0.3.0 // 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/pierrec/lz4 v2.6.1+incompatible // indirect
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.12 // indirect
golang.org/x/arch v0.8.0 // indirect
golang.org/x/crypto v0.26.0 // indirect
golang.org/x/net v0.28.0 // indirect
golang.org/x/sys v0.23.0 // indirect
golang.org/x/text v0.17.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/protobuf v1.34.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // 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.