dmarkham / enumer

A Go tool to auto generate methods for your enums
Other
410 stars 66 forks source link

Add build constraints to the exported file #52

Open XanderAtBackboneSystems opened 2 years ago

XanderAtBackboneSystems commented 2 years ago

First of all i'm a happy user of the enumer :) But i've an situation in which i need a bit of help.

When my enum is in code that is only build when certain constraints are met. (See: here) i'd like to have the constraints also in the generated code. If the build constraints not get exported the compile would generated errors as the generate file is build without the source containing the enum base definition.

I wrote a small PR in which i added a command line argument to add the build constraints. This works fine.

I was thinking whether it would be possible to deduct the build tags from the original source file and copy them into the generated one. But could not think of an easy way to that.

Note the comment option does not work as it adds a space between // and the first char of the comment

dmarkham commented 2 years ago

It seems I don't really understand the problem, or what you are trying to do. If you have some time to explain it to me, I'm down to do a call to you can walk me though it.