Home >Backend Development >Golang >Why Do I Get 'go: go.mod file not found' After a Go Update, and How Can I Fix It?

Why Do I Get 'go: go.mod file not found' After a Go Update, and How Can I Fix It?

Patricia Arquette
Patricia ArquetteOriginal
2024-12-11 15:38:16465browse

Why Do I Get

Resolving "go: go.mod file not found" Error after Go Update

When attempting to build a simple "Hello, World!" Go example after updating to Go version 1.16.2, you might encounter the following error:

go: go.mod file not found in current directory or any parent directory; see 'go help modules'

Attempts to resolve the issue using the suggested fix, setting GO111MODULE=on and GOPROXY=https://proxy.golang.org,direct, may not succeed.

To address this problem:

  1. Set GO111MODULE=off. Instead of setting it to auto, which might cause the issue, disable module support by setting it to off. This can be done using the command:
go env -w GO111MODULE=off

The above is the detailed content of Why Do I Get 'go: go.mod file not found' After a Go Update, and How Can I Fix It?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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