Go get cannot find main module (go modules)

Using go modules I’m unable to go get -v -u <some-repo>.

I created a test project for this with the following structure:

├── go.mod
└── main.go
0 directories, 2 files

The contents of the go.mod file are:

module github.com/pedromss/gomodinmain

After I push it to a repo I then perform the following steps:

  • go clean -i -r -x
  • remove the src folder from the file system with rm -rf
  • navigate outside of GOPATH
  • attempt a go get -v -u github.com/pedromss/gomaininroot to simulate someone that wants to start working on this and does not have the code locally

And I get the message:

go: cannot find main module; see 'go help modules'

If I do GO111MODULE=off go get -v -u github.com/pedromss/gomodinmain it works.

What am I doing wrong here?

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.