How it works...
Note that the preceding code represents two approaches. The parseWithRawBytes function uses the preferred approach, but it is highly dependent on the driver implementation. It works the way that the slice of RawBytes, with the same length as the number of the columns in the result, is created. Because the Scan function requires pointers to values, we need to create the slice of pointers to the slice of RawBytes (slice of byte slices), then it can be passed to the Scan function.
After it is successfully extracted, we just remap the values. In the example code, we cast it to the string because the driver uses the string type to store the values if the RawBytes is the target. Beware that the form of stored values depends on driver ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access