crawler_go/crawler_generalization_test.go

48 lines
522 B
Go
Raw Permalink Normal View History

2017-04-10 09:03:31 +00:00
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)
}
}