💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、豆包、星火、月之暗面及文生图、文生视频 广告
* 如果是map结构体用后就删除 * 结构体切片, 循环取出和放入 ~~~ package main import ( "fmt" "sync" ) type ResConnectorInfos struct { StationId string //充电站Id EquipmentId string //充电桩Id ConnectorId string //充电枪Id } func main() { ppFree := sync.Pool{New: func() interface{} { return new(ResConnectorInfos) }} res := ppFree.Get().(*ResConnectorInfos) res.StationId = "1" fmt.Printf("%p%v\n", res, res) res.StationId = "" res.ConnectorId = "" res.EquipmentId = "" ppFree.Put(res) res3 := ppFree.Get().(*ResConnectorInfos) fmt.Printf("%p%v\n", res3, res3) } ~~~