package main
import (
"fmt"
"sync"
)
func route(s []int) {
fmt.Println(s)
}
func main() {
batch := 2
records := []int{1, 2, 3, 4, 5, 6, 7, 8, 9}
fmt.Println(records[8:])
pos := 0
wg := new(sync.WaitGroup)
wg.Add(1)
for pos < len(records)-batch {
wg.Add(1)
go func() {
defer wg.Done()
route(records[pos : pos+batch])
}()
pos += batch
}
go func() {
defer wg.Done()
route(records[pos:])
}()
wg.Wait()
}
以上代码有什么bug吗?