对go语法感到困惑[重复]

This question already has an answer here:

Little bit confused with this code.

var _ QueryAppender = (*selectQuery)(nil)

I found this code in pg-go repository and don't know why QueryAppender declared that way. Please explain me what is the use cases when I should declare variables that way.

</div>

This doesn't do anything at runtime, but unless the *selectQuery type satisfies the interface QueryAppender, compilation will fail. It's a kind of static assertion.