What is this variable declaration with underscore, inline interface and assignment?
问题 What does this snippet of Go code do? var _ interface { add(string) error } = &watcher{} I believe &watcher{} returns two things, the first is discarded and the second is assigned to ... an interface? I found the code in fswatch on Github. 回答1: This construct will declare a variable with an blank identifier name with type given by a type literal; an interface definition in this case. What follows is in initializer expression - a pointer to a composite literal in this case. Overall