This is a short blog piece and really intended for fellow Go developers who stumble upon the same error, the dreaded “duplicate symbols” error.
Currently, some of Repustate’s Go code is using cgo to talk to various C libraries. It’s a stop gap until we finish porting all C code to pure Go. While writing some tests, we hit this error:
“ld: 1 duplicate symbol for architecture x86”
(note: if you had more than 1 duplicate, it would tell you exactly how many)
What does this mean? Well, it means we’re trying to link the same symbol name (in our case, a method) from two (or more) different source files. The fix was easy: rename one of the methods by updating the header file, the source file (.c or .cpp file) and lastly, updating your references to the symbol in your Go code, if it is directly referenced there.
Smooth sailing from here on in.