Исходники и презентации
This commit is contained in:
20
lessons/generics_and_reflection/reflect_implements/main.go
Normal file
20
lessons/generics_and_reflection/reflect_implements/main.go
Normal file
@ -0,0 +1,20 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
)
|
||||
|
||||
type Interface interface {
|
||||
Method()
|
||||
}
|
||||
|
||||
type Data struct{}
|
||||
|
||||
func (c Data) Method() {}
|
||||
|
||||
func main() {
|
||||
dataType := reflect.TypeOf(Data{})
|
||||
interfaceType := reflect.TypeOf((*Interface)(nil)).Elem()
|
||||
fmt.Println("implements:", dataType.Implements(interfaceType))
|
||||
}
|
||||
Reference in New Issue
Block a user