Skip to content
Node: Buffer.concat(list)github.com/sahilkhaire/gox/buffer

Buffer.Concat

Overview

Concat joins buffers (Buffer.concat).

If you are coming from Node.js, the closest pattern is Buffer.concat(list).

Method on Buffer — call it on a value of that type after constructing or receiving one from a constructor.

Signature

go
func Concat(parts ...Buffer) Buffer

Compare: Node.js · Standard Go · gox

js
Buffer.concat([buf1, buf2]);
go
b := append([]byte(nil), parts...)
go
import "github.com/sahilkhaire/gox/buffer"

combined := buffer.Concat(buf1, buf2)

Example

go
import "github.com/sahilkhaire/gox/buffer"

combined := buffer.Concat(buf1, buf2)

Tips

Obtain a Buffer value first (see constructors on the package overview), then call Concat.

Standard library alternative

Use the standard library directly:

go
b := append([]byte(nil), parts...)

Back to buffer package overview

MIT Licensed · Built for Node.js developers moving to Go