代码结构 - src - Flyweight.go # 定义抽象享元接口 - ConcreteFlyweight.go # 具体享元角色,实现抽象接口,用于共享状态 - UnsharedConcreteFlyweight.go # 无需共享的角色,实现抽象接口,每次都是新实例 - FlyweightFactory.go # 享元工厂,储存一个对象共享池 测试验证 $ cd ./flyweight-pattern/go $ go run test/test.go