go mod init headfirst //removed src directory from headfirst
go.mod //Added go.mod file
//go.mod
module headfirst
go 1.20
if I do this go run main.go it works only if main.go is inside headfirst module.
If I create main.go outside of module, then import doesn’t work.
How to handle this? I tried adding /headfirst to GOPATH, but came across this error: $GOPATH/go.mod exists but should not.
Why would you want to have your main.go outside the module(headfirst)… ur workspace only recognizes the contents of that module, everything else that would come in would be a absolute path
So if you want ur main.go outside headfirst but present in another module…and still talk to package in headfirst that example should be fine. good luck