- 博客(1)
- 收藏
- 关注
原创 GO loop variable captured by func literal
defer中出现的例子package mainimport "fmt"type Test struct { name string}func (t *Test) Close() { fmt.Println(t.name, " closed")}func main() { ts := []Test{{"a"}, {"b"}, {"c"}} for _, t := range ts { defer t.Close() }}输出
2021-06-28 22:19:27 4403
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人