crawler_go/crawler_generalization_test.go
jackdaw@loafle.com 8ecf62ec30 .
2017-04-10 18:03:31 +09:00

48 lines
522 B
Go

package crawler
import (
"fmt"
"testing"
)
type Super interface {
Method()
}
type sss struct{}
func (s *sss) Method() {
fmt.Println("Super")
}
type Child struct {
sss
}
func (c *Child) Method() {
c.sss.Method()
fmt.Println("Child")
}
func TestGene(t *testing.T) {
c := Child{}
c.Method()
var s Super = &Child{}
s.Method()
}
func TestExistInterface(t *testing.T) {
m := make(map[string]Super, 0)
m["test"] = &Child{}
_, ok := m["test1"]
if ok {
fmt.Println(ok)
} else {
fmt.Println(ok)
}
}