Go (Golang) Otel Duplicate Method Private
Yesterday we got the following strange-looking error trying to compile our Go code:
vendor/go.opentelemetry.io/otel/trace/config.go:117:2: duplicate method private
The whole issue of duplicate methods is quite fun in itself, and you can read a good explanation here if you’re interested: https://stackoverflow.com/questions/43730255/how-to-deal-with-duplicate-methods-in-go-interface/43733306
However, in this case we are dealing with an existing outside package (OpenTelemetry), so fixing the code directly isn’t an option. Besides, it is working for other people and services.
It turned out that this problem is specific to go version 1.13. So at this point, the best thing to do if you are hitting this problem is to update your go version to 1.14 or higher.
The tricky part in our case was that the main code was compiling just fine, but the component tests threw the error. So in the end, it turned out to be that, even though the go version on my system was 1.15, the version of the source image which was used to build the docker image for component tests was outdated.
So, double-check not only your system go version, but also your dockerfiles. :)