append() 并发安全问题

📝

内容提要

由来: 今天在编程过程中遇到这样一个问题,并发把数据写入到切片中。 var posts []int func hello(i int) { defer wg.Done() // goroutine结束就登记-1 posts = append(posts, i) } func main() { for i := 0;

🏷️

标签

➡️

继续阅读