Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

affected/package: The go.mod file is in the current directory, but when executing the program, it says that go.mod cannot be found #59850

Closed
yxxchange opened this issue Apr 26, 2023 · 1 comment

Comments

@yxxchange
Copy link

I'm running a go program that imports a third-party package. When I execute, the program execution fails with the following error:
main.go:7:2: no required module provides package github.com/goinaction/code/chapter2/sample/matchers: go.mod file not found in current directory or any parent directory; see 'go help modules'
I'm sure the go.mod file exists in the current directory, as shown in the image below:
image
The command what I excute is go run ./main.go
go mod tidy or go mod init is helpless.

environment:wsl2+ubuntu22.04

What version of Go are you using (go version)?

$ go version
go version go1.20.3 linux/amd64

Does this issue reproduce with the latest release?

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
  GO111MODULE="auto"
  GOARCH="amd64"
  GOBIN=""
  GOCACHE="/home/yxx/.cache/go-build"
  GOENV="/home/yxx/.config/go/env"
  GOEXE=""
  GOEXPERIMENT=""
  GOFLAGS=""
  GOHOSTARCH="amd64"
  GOHOSTOS="linux"
  GOINSECURE=""
  GOMODCACHE="/home/yxx/go/pkg/mod"
  GONOPROXY=""
  GONOSUMDB=""
  GOOS="linux"
  GOPATH="/home/yxx/go"
  GOPRIVATE=""
  GOPROXY="https://goproxy.cn"
  GOROOT="/usr/local/go"
  GOSUMDB="sum.golang.org"
  GOTMPDIR=""
  GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
  GOVCS=""
  GOVERSION="go1.20.3"
  GCCGO="gccgo"
  GOAMD64="v1"
  AR="ar"
  CC="gcc"
  CXX="g++"
  CGO_ENABLED="1"
  GOMOD="/home/yxx/GoProject/go.mod"
  GOWORK="/home/yxx/GoProject/go.work"
  CGO_CFLAGS="-O2 -g"
  CGO_CPPFLAGS=""
  CGO_CXXFLAGS="-O2 -g"
  CGO_FFLAGS="-O2 -g"
  CGO_LDFLAGS="-O2 -g"
  PKG_CONFIG="pkg-config"
  GOGCCFLAGS="-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build1222502426=/tmp/go-build -gno-record-gcc-switches"

What did you do?

What did you expect to see?

The program executes normally

What did you see instead?

main.go:7:2: no required module provides package github.com/goinaction/code/chapter2/sample/matchers: go.mod file not found in current directory or any parent directory; see 'go help modules'

@seankhliao
Copy link
Member

Please don't use screenshots, they're hard to read.

This isn't enough information for us to diagnose any issue, notably missing are the contents of files (and they diverge from the repo you've cloned), the exact commands including where you ran them. Your bug report data also doesn't match the situation you've described.

Unlike many projects, the Go project does not use GitHub Issues for general discussion or asking questions. GitHub Issues are used for tracking bugs and proposals only.

For questions please refer to https://github.com/golang/go/wiki/Questions

@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Apr 26, 2023
@golang golang locked and limited conversation to collaborators Apr 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants