Home >Backend Development >Golang >Strange behavior when downloading my module
php Editor Banana's issue about strange behavior when downloading modules may be due to a variety of reasons. Sometimes, downloaded modules may be corrupted or incomplete, which may cause strange behavior. Alternatively, download issues may be caused by server or network connection issues. Before solving this problem, we need to carefully examine these possible causes and take appropriate measures to solve it. Next, I will provide you with some methods and suggestions to solve this problem.
Whenever I use go get to download a module I made (https://github.com/torbenconto/plutus), it won't let me use any subpackage, Until I ran go mod tidy on the project I downloaded it worked. Please help me, I don't know how to solve this problem!
This is my module’s 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 )
This is the error code I receive when I hover over the red underlined import of the module Unable to import github.com/torbenconto/plutus/quote (No required module provides package 'github.com/torbenconto/plutus/quote') compilerBrokenImport
The problem is solved when I run go mod tidy in the project with the downloaded module. The go.mod in the project where it was downloaded becomes like this before running go mod tidy
module test go 1.21.1 require ( github.com/torbenconto/plutus v1.4.1 // indirect )
Go here after running
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 )
please help.
I tried running go mod tidy in the project without success, as well as many other things I found on google. After hours of troubleshooting, nothing has worked so far.
By importing the module used by the sub-package (colly-go in this case) in my main file (plutus.go), causing go get to retrieve all needed module, solved my problem.
The above is the detailed content of Strange behavior when downloading my module. For more information, please follow other related articles on the PHP Chinese website!