golang design pattern go 设计模式实现,包含 23 种常见的设计模式实现,同时这也是极客时间-设计模式之美 的笔记
2.04k
stars
339
forks
source link
单例本身没有问题,但是你代码中 singleton 的申明是需要加上字段的;另外 assert.Equal 直接调用也是有问题的,不会判断地址值而是判断的对象值。参考:[https://github.com/stretchr/testify/issues/1076](https://github.com/stretchr/testify/issues/1076) #12
Closed
mohuishou closed 1 year ago
所以你的 singleton_test 并没有达到实际的测试效果,只是“负负得正”而已。一个正确的单测:
Originally posted by @xyling1024 in https://github.com/mohuishou/go-design-pattern/issues/2#issuecomment-1534680832