go module_error ai_generated true

no required module provides package github.com/foo/bar; to add it: go get github.com/foo/bar

ID: go/cannot-find-module-providing-package

Also available as: JSON · Markdown · 中文
80%Fix Rate
90%Confidence
0Evidence
2024-01-22First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
1.16+ active — — —
1.21+ active — — —

Root Cause

The import is used in source but go.mod has no require entry for the providing module, and -mod=readonly prevents auto-adding.

generic

中文

源码中使用了该导入,但 go.mod 中没有提供该模块的 require 条目,且 -mod=readonly 阻止自动添加。

Workarounds

  1. 95% success
    go get github.com/foo/bar@latest
    go mod tidy
  2. 90% success
    go build -mod=mod ./...

Dead Ends

Common approaches that don't work:

  1. 70% fail

    wrong version causes 'unknown revision' or checksum errors

  2. 90% fail

    build fails with 'vendor directory does not exist'

  3. 60% fail

    loses all existing dependency pins and may break transitive deps