Skip to main content

NewBytesReadCloser

No overview available.

def NewBytesReadCloser(
b: []byte
) - > io.ReadCloser

Creates a new io.ReadCloser from a byte slice. This function is useful when you need to treat an in-memory byte array as a readable and closable stream, for example, when an API expects an io.ReadCloser but your data is already in memory.

Parameters

NameTypeDescription
b[]byteThe byte slice to be wrapped as an io.ReadCloser.

Returns

TypeDescription
io.ReadCloserA new io.ReadCloser instance that reads from the provided byte slice.