-
With a magefiles directory, or just any mage file that has package main set, how do you import its targets with mage:import? I have a package https://github.com/anacrolix/publicip that exposes some useful methods that don't quite conform to mage's target function signature requirements. If I make a mage file that wraps them for use by mage, I can't also have that file be a valid standalone mage file if I want to import those targets by another mage file. I think the work around is to create a mage "library" package? To extend the specific problem I have with making a mage file for anacrolix/publicip, the names of the targets that I want exactly match what's being wrapped. Is there any way to still include the mage target wrappers in the root package? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
We plan to make the magefiles directory not require that it be For now, your best bet is to put the code that isn't mage targets into a different package (i.e. a different directory) and just import it like normal code. If you really need both the targets and these other functions in the same package, you can use mage:import to import the targets, and then import and use the other functions normally. |
Beta Was this translation helpful? Give feedback.
We plan to make the magefiles directory not require that it be
package main
but haven't gotten that code written yet.For now, your best bet is to put the code that isn't mage targets into a different package (i.e. a different directory) and just import it like normal code.
If you really need both the targets and these other functions in the same package, you can use mage:import to import the targets, and then import and use the other functions normally.