go-pattern-examples/creation/01_new/new_test.go

28 lines
333 B
Go
Raw Permalink Normal View History

2020-04-24 18:44:16 +03:00
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()
}