-1

I am trying to understand the effect of global variable _ from graph's source code like the belowing code, but at last I can't figure out what's the meaning.

type variable_ interface {
    cin()
}

type imple struct {
}

func (i *imple) cin() {
    fmt.Println("cout")
}

var (
    _ = variable_((*imple)(nil))
)
Volker
  • 40,468
  • 7
  • 81
  • 87
cherry
  • 11
  • 1
  • 1
    Duplicate: _ means always the same: Ignore it. The interesting thing is `variable_((*imple)(nil))` which you cannot put into code without a variabel (you do not care about). `variable_((*imple)(nil))` is a compile time check that `*impl` implements `variable_`. – Volker Aug 18 '22 at 08:33

1 Answers1

1

_ always means ignore in GO. the purpose of _ = variable_((*imple)(nil)) is to check at compile time if *impl implements variable_