Does go have preprocessor (#)

Like c has # which runs before compilation. Does GoLang has anything like this.

Go has Build Constraints.

1 Like

can we use build constrains any where in the code or only at the starting.

Did you read the documentation?

Constraints may appear in any kind of source file (not just Go), but they must appear near the top of the file, preceded only by blank lines and other line comments

I have seen the documentation.
In that they have stated that build tags are defined in the start.But I want then to use in the middle of the file and in between the functions.

If i have to use it in the starting then i have to create 2 files but i want it to be done in 1 file.

Is it possible?(To do both unix and windows def in single file)


It is easier to use the tools provided. Separate the implementation into two files.

Got it. Thanks @lutzhorn

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.