Conditional compilation in Go

cgo, go

Solution

Go does not have conditional compilation or conditional imports. Handle the type differences in C code.

Are the [Go] authors opposed to preprocessing?

Problem

I'm trying to write a Go wrapper using CGo for ENet. When I tried to compile my wrapper on a Mac the library was older and had a slightly different interface. 99% of the code is the same just a few C calls need to change. What is the best practice for dealing with a problem like this in Go? Is there some way to do conditional compilation or conditional imports?

Original source