Standard library / bytes

bytes.Join()

Concatenates elements with the separator inserted between adjacent elements, never after the last. Expected stdout: 'a-b\n'.

Formal Syntax & Structure

go syntaxgo
func Join(s [][]byte, sep []byte) []byte

Parameters & Attributes

NameTypeDescription
s[][]byteByte slices to concatenate.
sep[]byteSeparator or search sequence.

Return Value

[]byte

Concatenates elements with the separator inserted between adjacent elements, never after the last.

Working Example

Example Snippetgo
package main
import (  "bytes"  "fmt")
func main() {  fmt.Println(string(bytes.Join([][]byte{[]byte("a"), []byte("b")}, []byte("-"))))}
Go Reference