- 使用
sync.Pool
包 - 单例对象(比如容器)
比如gin框架
使用第一种方式来解决context复用问题
不知道我理解的对不对,或者还有其他方式
###偷个懒行不行?
type Test struct {
}
func main() {
container := make(map[string]interface{})
t := &Test{}
container["test"] = t
t := container["test"].(*Test)
}