Buffer.FromString
Overview
FromString creates a buffer from a string.
If you are coming from Node.js, the closest pattern is Buffer.from(str).
Method on Buffer — call it on a value of that type after constructing or receiving one from a constructor.
Signature
go
func FromString(s string) BufferCompare: Node.js · Standard Go · gox
js
Buffer.from(str)go
b := append([]byte(nil), parts...)go
import "github.com/sahilkhaire/gox/buffer"
buffer.FromString(str)Example
go
import "github.com/sahilkhaire/gox/buffer"
buffer.FromString(str)Tips
Obtain a Buffer value first (see constructors on the package overview), then call FromString.
Standard library alternative
Use the standard library directly:
go
b := append([]byte(nil), parts...)