pacedotdev / batch

Very simple batching API for Go.

Home Page:https://pace.dev/blog/2020/02/13/batching-operations-in-go-by-mat-ryer

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Indexing bug in batchItems slicing

IsmailAfiff opened this issue · comments

In the tutorial, the usage of the function is batchItems := items[start:end].
Golang slice is exclusive meaning the end is not included in the slice, therefore it should be batchItems := items[start:end+1].

You mean :end+1] ?

Yap you're right it should be :end+1

Any plans to either update the blog post or fix the issue here directly.

I of course understand that it's a breaking change and so probably not ideal, despite my shared thinking that [start:end] is the correct and assumed treatment regardless of what the blog post says, others may disagree. So, updating the post seems worthwhile to IMHO.