-
Notifications
You must be signed in to change notification settings - Fork 256
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Magefile can't use application code defined in the same directory #188
Comments
Can you run mage -l -debug in that directory and paste that here? This sounds like a bug, probably introduced with the changes I made for 1.7. |
Sure thing. Here's a simple case, with just these two files saved in // +build mage
// Mage.go
package main
import (
"fmt"
"github.com/magefile/test"
)
func Run() {
fmt.Println(test.Message())
} // app.go
package app
func Message() string {
return "success!"
} Output:
|
Oh, actually, I am pretty sure I know exactly what it is. Is your magefile importing a package that has some files marked as (actually... it looks like your magefile is importing the current directory it's in, is that right?) |
Yeah, that directory has application code sitting side-by-side with the Magefile, and the application code doesn't have the |
Adding
|
Yeah, it looks like removing the |
This is just my mistake for adding the mage build tag to what's being built. I'll fix it and make a v1.7.1 ASAP. Yeah... I thought it would be harmless in case someone marked imported code with the mage build tag, but it didn't occur to me that this means you can't import code from a package that has both magefile |
No worries at all, thanks for the quick response! |
If you don't mind, can you try checking out the |
I have an application whose design is inspired by this post; in particular, domain objects are all stored in the application's root package, which is also the top-level folder of the repository. Since it's the top of the repository, I also have my main Magefile defined there, and lately it's been failing to compile because it finds two packages in that directory:
main
and (for example)app
:This used to work, so I'm not sure what recent change actually caused it to break. The version of Mage I'm using:
The workaround seems to be pretty simple, which is to move application code down one level, leaving the Magefile as the sole Go file at the root. This is kind of annoying though, since it requires re-architecting the application in order to avoid compilation errors.
The text was updated successfully, but these errors were encountered: