golang: NewReader vs NewBufferString

NewReader

func bytes.NewReader(b []byte) *bytes.Reader

bytes.NewReader on pkg.go.dev

NewReader returns a new Reader reading from b.

NewBufferString

func bytes.NewBufferString(s string) *bytes.Buffer

bytes.NewBufferString on pkg.go.dev

NewBufferString creates and initializes a new Buffer using string s as its initial contents. It is intended to prepare a buffer to read an existing string.

--

--

--

Golang, Distributed Systems, File Systems, Python, C/C++, Linux

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Visualizing an iOS device in Blender Through Quantum Entanglement

Docker basic commands

Objective-C Runtime Notes

Google Cloud Anthos Series: Anthos Platform Introduction

Image Picker in Flutter

Building A Responsive Coming Soon Page In Less Than 10 Minutes😱💖

8 Outlook Alternatives: Best For Windows, Free, Mobile and Mac

Isaac’s log

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Simplify Complexity

Simplify Complexity

Golang, Distributed Systems, File Systems, Python, C/C++, Linux

More from Medium

Go-tcha: When nil != nil

Golang: Curious Case of Returning Byte Array and Conversion to Byte Slice

TicTacGo — An Intro to Golang

WaitGroup caveat for a Go layman