Search code examples
gomodulego-modules

Weird behavior when downloading my module


Whenever I download a module i made (https://github.com/torbenconto/plutus) using go get, it doesn't let me use any of the sub packages until i run go mod tidy on the project i downloaded it to. Please help me I have no idea how to fix this!

This is the go.mod of my module

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
)

And this is the error code i get when hovering over the red underlined import of my module could not import github.com/torbenconto/plutus/quote (no required module provides package "github.com/torbenconto/plutus/quote")compilerBrokenImport

The issue is resolved when i run go mod tidy in the project that downloaded the module. The go.mod in the project that downloaded it turns from looking like this before running go mod tidy

module test

go 1.21.1

require (
    github.com/torbenconto/plutus v1.4.1 // indirect
)

to this after running it

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 have tried to run go mod tidy in the project to no avail along with many other things i found on google. So far nothing has worked after a few hours of troubleshooting.


Solution

  • My issue was fixed by importing the modules that were used by the sub packages (colly-go in this case) in my main file (plutus.go) causing go get to retrieve all the needed modules.