1.必备技能 - webpack学习之路
410 2023-04-03 03:28:20
package factoryimport "fmt"type Company interface {Goodjob()}type Thinry struct {}func (m *Thinry) Goodjob() {fmt.Println("Thinry 9点开始进入工作")}type Shine struct {}func (m *Shine) Goodjob() {fmt.Println("Shine 9点30开始进入工作")}func NewConpany(cType string) Company {switch cType {case "jit":return &Thinry{}case "shine":return &Shine{}}return nil}
package factoryimport "testing"func TestNewCompany(t *testing.T) {NewConpany("jit").Goodjob()NewConpany("shine").Goodjob()}
Thinry 9点开始进入工作Shine 9点30开始进入工作