Questions tagged «underscores»

2
关键字var后的下划线和接口名称是什么意思?
从http://golang.org/src/pkg/database/sql/driver/types.go中: type ValueConverter interface { // ConvertValue converts a value to a driver Value. ConvertValue(v interface{}) (Value, error) } var Bool boolType type boolType struct{} var _ ValueConverter = boolType{} // line 58 func (boolType) String() string { return "Bool" } func (boolType) ConvertValue(src interface{}) (Value, error) {....} 我知道ValueConverter是接口名称。第58行似乎声明了boolType实现接口ValueConverter,但这是否必要?我删除了58行,代码运行良好。
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.