3 ms·
Coming from a C background, I was pretty disgusted with the "hack" of adding the include files in a comment before 'import C'. But then, even though they look s
by AceJohnny2 13y ago
Coming from a C background, I was pretty disgusted with the "hack" of adding the include files in a comment before 'import C'. But then, even though they look similar, Go doesn't treat comments like C does, where they're eliminated by the C preprocessor and completely invisible to the source.
- catnaroek 13y agoYou use C! You have no right to complain about ugly hacks! (jk)
- james4k 13y agoThis is because cgo is actually a preprocessor that generates the final C and Go code that is built. The tools are just good at hiding this. Personally, I wouldn't say this is a bad thing. You can do some powerful things with this, including using your own .c and .h files in your Go packages. For a while, the YAML package at launchpad.net/goyaml did this by using libyaml code directly instead of having to link to external libraries, though now it is pure Go.