卓越飞翔博客卓越飞翔博客

卓越飞翔 - 您值得收藏的技术分享站
技术文章35167本站已运行394

下载我的模块时出现奇怪的行为

下载我的模块时出现奇怪的行为

php小编香蕉有关下载模块时出现奇怪行为的问题,可能是由于多种原因导致的。有时候,下载的模块可能损坏或不完整,这可能会导致奇怪的行为。另外,也有可能是由于服务器或网络连接问题导致的下载问题。在解决这个问题之前,我们需要仔细检查这些可能的原因,并采取相应的措施来解决。接下来,我将为您提供一些解决这个问题的方法和建议。

问题内容

每当我使用 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,但没有成功,以及我在谷歌上找到的许多其他东西。经过几个小时的故障排除后,到目前为止没有任何效果。

解决方法

通过在我的主文件 (plutus.go) 中导入子包(在本例中为 colly-go)使用的模块,导致 go get 检索所有需要的模块,解决了我的问题。

卓越飞翔博客
上一篇: 如何在 Golang 中对 io.PipeRaeder 进行非阻塞 Read()
下一篇: 返回列表
留言与评论(共有 0 条评论)
   
验证码:
隐藏边栏