NewBytesReadCloser
Creates a new io.ReadCloser from a byte slice. The returned io.ReadCloser wraps a bytes.Reader initialized with the provided byte slice.
def NewBytesReadCloser(
b: []byte
) - > io.ReadCloser
Creates a new io.ReadCloser from a byte slice. This function is useful for treating an in-memory byte array as a readable and closable stream, allowing it to be used with APIs that expect an io.ReadCloser.
Parameters
| Name | Type | Description |
|---|---|---|
| b | []byte | The byte slice to be wrapped as an io.ReadCloser. The returned reader will read directly from this slice. |
Returns
| Type | Description |
|---|---|
io.ReadCloser | A new io.ReadCloser instance that reads from the provided byte slice. |