[GODRIVER-3025] Create a peeking methodology for bson.Decode Created: 30/Oct/23  Updated: 30/Oct/23

Status: Backlog
Project: Go Driver
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Unknown
Reporter: Preston Vasquez Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to GODRIVER-3024 Runtime Error 'index out of range' in... Backlog
is related to GODRIVER-2835 Support reading a stream of BSON docu... Backlog

 Description   

The Go Driver is missing the dec.peek() analogue that encoding/json has, which can be efficiently used to determine if there is more data in the stack: https://cs.opensource.google/go/go/+/refs/tags/go1.21.3:src/encoding/json/stream.go;l=482

This functionality is extremely useful. Rather than checking the length of a buffer or relying on catching the io.EOF error a user can exhaust the stack iteratively:

for dec.More() {
  // Do stuff
} 


Generated at Thu Feb 08 08:39:54 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.