ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
~~~ package abstractfactory import ( "fmt" "testing" ) func TestAbstractFactory(t *testing.T) { uData := User{1, "u"} dData := Department{1, "d"} data := DataAccess{} iU := data.createUser("access") iU.insert(&uData) gU := iU.getUser(1) fmt.Println(gU) fmt.Println("================") iD := data.createDepartment("sqlserver") iD.insert(&dData) gD := iD.getDepartment(1) fmt.Println(gD) if iS := data.createDepartment("a"); iS != nil { t.Error() } } ~~~