刚接触 golang。我试图存储从我们的应用程序端发送的所有航点,但批量大小为 100,这是我的代码
json.NewDecoder(r.Body).Decode(payload)
// seperate waypoints into groups
limit := 100
seperated := [][]*waypoint.Waypoint{}
// payload is from api call, basically plain json data
for i, wp := range payload.Batch {
if i%limit == 0 {
seperated = append(seperated, []*waypoint.Waypoint{})
}
last := seperated[len(seperated)-1]
last = append(last, wp)
}
不知道什么持续了很长时间,但似乎我无法达到我的预期..
肥皂起泡泡
相关分类