Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does this golang code do? [duplicate]

Tags:

go

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?

like image 529
codefx Avatar asked Dec 11 '22 19:12

codefx


1 Answers

This line is a compile time check that *DropletsServiceOp satisfies the DropletsService interface.

The line has no effect on the execution of the program.

like image 64
Bayta Darell Avatar answered Dec 28 '22 23:12

Bayta Darell