每当我使用 go get 下载我制作的模块(https://github.com/torbenconto/plutus)时,它不会让我使用任何子包,直到我在我下载的项目上运行 go mod tidy它到。请帮助我,我不知道如何解决这个问题!
这是我模块的go.mod
module github.com/torbenconto/plutus/api
go 1.21
toolchain go1.21.1
require (
github.com/gin-gonic/gin v1.9.1
github.com/torbenconto/plutus v1.3.0
)
require (
github.com/PuerkitoBio/goquery v1.8.1 // indirect
github.com/andybalholm/cascadia v1.3.2 // indirect
github.com/antchfx/htmlquery v1.3.0 // indirect
github.com/antchfx/xmlquery v1.3.18 // indirect
github.com/antchfx/xpath v1.2.5 // indirect
github.com/bytedance/sonic v1.10.2 // indirect
github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d // indirect
github.com/chenzhuoyu/iasm v0.9.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.16.0 // indirect
github.com/gobwas/glob v0.2.3 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/gocolly/colly/v2 v2.1.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/kennygrant/sanitize v1.2.4 // indirect
github.com/klauspost/cpuid/v2 v2.2.6 // indirect
github.com/leodido/go-urn v1.2.4 // 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.1.1 // indirect
github.com/saintfish/chardet v0.0.0-20230101081208-5e3ef4b5456d // indirect
github.com/temoto/robotstxt v1.1.2 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.12 // indirect
golang.org/x/arch v0.6.0 // indirect
golang.org/x/crypto v0.17.0 // indirect
golang.org/x/net v0.19.0 // indirect
golang.org/x/sys v0.15.0 // indirect
golang.org/x/text v0.14.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/protobuf v1.32.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
这是我将鼠标悬停在模块的红色下划线导入上时收到的错误代码 无法导入 github.com/torbenconto/plutus/quote (没有必需的模块提供包“github.com/torbenconto/plutus/quote”)compilerBrokenImport
当我在下载模块的项目中运行 go mod tidy 时,问题得到解决。 下载它的项目中的 go.mod 在运行 go mod tidy 之前变成了这样
module test
go 1.21.1
require (
github.com/torbenconto/plutus v1.4.1 // indirect
)
运行后到此
module test
go 1.21.1
require github.com/torbenconto/plutus v1.4.1
require (
github.com/PuerkitoBio/goquery v1.8.1 // indirect
github.com/andybalholm/cascadia v1.3.2 // indirect
github.com/antchfx/htmlquery v1.3.0 // indirect
github.com/antchfx/xmlquery v1.3.18 // indirect
github.com/antchfx/xpath v1.2.5 // indirect
github.com/gobwas/glob v0.2.3 // indirect
github.com/gocolly/colly/v2 v2.1.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/kennygrant/sanitize v1.2.4 // indirect
github.com/saintfish/chardet v0.0.0-20230101081208-5e3ef4b5456d // indirect
github.com/temoto/robotstxt v1.1.2 // indirect
golang.org/x/net v0.19.0 // indirect
golang.org/x/text v0.14.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
请帮忙。
我尝试在项目中运行 go mod tidy,但没有成功,以及我在谷歌上找到的许多其他东西。经过几个小时的故障排除后,到目前为止没有任何效果。
结构似乎是错误的。理想情况下,1 个 go 项目应该有单个
go.mod
和 go.sum
文件。
|- github.com/torbenconto/plutus
|--- go.mod
|--- go.sum
|---internal
|---api
|----api.go
您已在
github.com/torbenconto/plutus/api
和 github.com/torbenconto/plutus
中添加了两次文件。
从
api
文件夹中删除 go.mod 和 go.sum。如果你想使用 api,请像这样使用 import github.com/torbenconto/plutus/api
。
还有
api
的包名错误。应该喜欢package api
。