-3

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.

latsha
  • 1,298
  • 1
  • 14
  • 22

1 Answers1

1

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.

Paul Hankin
  • 54,811
  • 11
  • 92
  • 118