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) []byteParameters & Attributes
| Name | Type | Description |
|---|---|---|
| s | [][]byte | Byte slices to concatenate. |
| sep | []byte | Separator 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("-"))))}