Basically what is happening, first we iterate over messages with index i and when we delete we override the messages. But once we delete an element from messages the index i from the outer loop is already outdated and we can't rely on it.
The solution is to switch loops, iterate over deleteEntries first and then start looking for message to be deleted, so index i always will be actual.
There is a bug inside
DeleteMessageBatch
function (issue https://github.com/p4tin/goaws/issues/171):Basically what is happening, first we iterate over messages with index
i
and when we delete we override the messages. But once we delete an element from messages the indexi
from the outer loop is already outdated and we can't rely on it. The solution is to switch loops, iterate overdeleteEntries
first and then start looking for message to be deleted, so indexi
always will be actual.