This question already has an answer here:
I was reading DigitalOcean's golang client. I noticed that they create an instance of their *Op struct in a _
variable. Example: https://github.com/digitalocean/godo/blob/master/droplets.go#L32
var _ DropletsService = &DropletsServiceOp{}
Why is this line needed?
</div>
This line is a compile time check that *DropletsServiceOp satisfies the DropletsService interface.
The line has no effect on the execution of the program.
If you look at the blame on that file, at that line, you get a clue:
https://github.com/digitalocean/godo/blame/master/droplets.go#L32
It does a compile-time check that *DropletsServiceOp
satisfies the DropletsService
interface. Prior to the commit introducing that, they were doing this in their test suite.