Go modules build error

Hello,

When I try to build a project using go modules It gives me an error like this

unknown import path "github.com/X/Y: cannot find module providing package github.com/X/Y.

Why it tries to find the project itself as a dependency? I also cleaned the cache but it didn’t help.

Thanks,

I tried both with GOPATH and without GOPATH. I assume using Go modules, we don’t need to use GOPATH anymore correct?

My code structure is
go.mod
Cmd
app1
app2
pkg

And I try to build the project from the root using go build

if you are creating project in workspace folder like “$HOME/go/github.com/username/project”, try to create your project outside of workspace dir. I mean outside of $HOME/go dir.

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