I have code in my project that will only work compiling it for windows, I am wanting to know if there is something i can put in code wise that will tell the compiler to ignore these functions and imports if compiling for not windows systems. So i don't have to edit the files everytime i compile for another system.
评论:
brianketelsen:
SaturnsVoid:yes! The simplest thing to do is add your windows specific code to a file called mystuff_windows.go see this great article: https://dave.cheney.net/2013/10/12/how-to-use-conditional-compilation-with-the-go-build-tool
RandNho:Thanks will look into this!
dchapes:Some people do horrible stuff with runtime os detection.
That's wrong and bad. Conditional compilation, as was said, is the way.
They're called build constraints.