Why Does 'go build' Fail with 'module ... found but does not contain package' Error?

Mary-Kate Olsen
Release: 2024-11-13 16:51:02
Original
715 people have browsed it

Why Does

"go module @latest found but does not contain package" Issue

When using Go modules for the first time, you may encounter the error message:

module github.com/mkideal/cli@latest found (v0.2.2), but does not contain package github.com/mkideal/cli
module github.com/mkideal/cli@latest found (v0.2.2), but does not contain package github.com/mkideal/cli/ext
Copy after login

This error occurs during go build and is not encountered during go get, indicating that the issue may not lie with the proxy settings or the Go module/package.

In this case, the root cause of the problem is a cached copy of the module metadata in the Go module cache. To resolve this, run the following command:

go clean -modcache
Copy after login

This command clears the Go module cache, allowing Go to download the latest metadata for the module and its dependencies. This ensures that the package versions and their contents are accurately reflected during the go build process.

The above is the detailed content of Why Does 'go build' Fail with 'module ... found but does not contain package' Error?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template