Go: no required module provides package github.com/foo/bar; to add it: go get github.com/foo/bar
The code imports a package whose module is not listed in go.mod.
no required module provides packagego: go.mod file not found in current directory or any parent directoryno required module provides package github.com/foo/bar; to add it: go getcannot find module providing packagego: cannot find main module, but found .git/config Meaning
Run go get github.com/foo/bar or go mod tidy. If the import path is wrong, fix it. Outside a module you'll see go: go.mod file not found in current directory or any parent directory — run go mod init first.
Common causes
- Dependency never added
- Typo in import path
- Running outside the module directory
- Package moved to a new module path (v2 suffix)
- Private repository not fetched
⚡ Quick fix
go get github.com/foo/bar@latestgo mod init example.com/appif there is no go.mod- Check major version suffix (
/v2)
Detailed fix by platform
Go
go list -m allshows the resolved module graph
How to diagnose
- Module — Listed in go.mod?
- Path — Correct (v2+)?
- Directory — Inside the module?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
- cannot find package in any of GOROOT / GOPATH Go: cannot find package "github.com/pkg/errors" in any of: /usr/local/go/src/github.com/pkg/errors (from $GOROOT) /go/src/github.com/pkg/errors (from $GOPATH)
- go: updates to go.mod needed Go: go: updates to go.mod needed; to update it: go mod tidy
- import cycle not allowed Go: package app/models imports app/utils imports app/models: import cycle not allowed
Most viewed in Go
Other ways to find it
Where this error sits
Origin: Application & API. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 4 Nov 2026