go-pattern-examples/creation/25_new/new_test.go
2020-04-24 23:44:16 +08:00

28 lines
333 B
Go

package newpattern
import (
"fmt"
"testing"
)
type homecat interface {
sleep()
}
type blackCat struct {
name string
}
func newBlackCat(name string) homecat{
return &blackCat{name}
}
func (b blackCat) sleep() {
fmt.Print( b.name + " is sleeping")
}
func TestNewMode(t *testing.T){
cat := newBlackCat("pi")
cat.sleep()
}