Open natefinch opened 5 years ago
I am currently experiencing this issue. I don't fully understand your workaround because I already have a go.mod file for the go code I'm building.
Is there a way to maintain two separate go.mod files without forcing the root of my project and the root of my code to be different?
if there's already a go.mod in the folder tree you're working in (either in the same directory or a parent directory), then this doesn't apply. The only place it would apply is if you want to be able to run mage on a file where there's no go.mod and it's outside gopath.
Kind of hurts the magefile for non- golang use case. I get I can use a magefiles directory, but would still be nice to find some workaround.
We can probably have mage create the go.mod and go.sum if they don't exist. I think they would need to stick around and not get auto-deleted, though, since most go tooling won't work without them.
If you run mage in a package outside gopath (i.e. using modules), when it tries to run
go list
to determine the files it needs to build,go list
will fail with "go: cannot determine module path for source directory" . This then causes mage to fail with "unable to determine magefiles".This can be fixed by having mage create a go.mod with just
module magefile
inside it... but then the go tool will hit the internet to look for the latest version of whatever imports you have. But that's probably better than just failing.