Reputation: 11100
So I have a GOPATH set to my working directory and I create a new script file.go. In that script I use I import "github.com/..."
I ran 'go get github.com/... and it appeared to download but when running go run file.go
I still get: no required module provides package github.com/gordonklaus/portaudio: go.mod file not found in current directory or any parent directory; see 'go help modules'
.
I tried adding go.mod
but then the error just changes to:
go: no module declaration in go.mod. To specify the module path:
go mod edit -module=example.com/mod
So I adding the following to my go.mod
file and it looks like this now:
module MyModuleName
go 1.17
require(
"github.com/..." v1.2.3
)
But I get:
missing go.sum entry for module providing package github.com/...; to add:
go mod download github.com/...
But when I run go mod download github.com/...
I get:
github.com/[email protected]: invalid version: unknown revision v1.2.3
So I don't know what todo from here.
Upvotes: 2
Views: 16234
Reputation: 109
If someone having similar error:
go: no module declaration in go.mod. To specify the module path:
go mod edit -module=example.com/mod
while trying to run some go code like go run test.go
, the following helped me to eliminate the error:
GO111MODULE=on go run test.go
After that I was able to run go code normally, without specifying GO111MODULE
variable.
Upvotes: 0
Reputation: 1325037
I would:
go.mod
and remove the line where v1.2.3 isgo get github.com/gordonklaus/portaudi
(executed in the project folder, where go.mod
is)go mod tidy
The end result should be the library added with a tag matching its latest release.
Upvotes: 3