Golang bytes.Join() function example
package bytes
Join concatenates the elements of input slice to create a new byte slice. A separator is placed between elements in the resulting slice.
Golang bytes.Join() function usage example
package main
import (
"bytes"
"fmt"
)
func main() {
a := []byte("Hello")
b := []byte(" World!")
c := [][]byte{a, b}
d := []byte{}
d = bytes.Join(c, []byte(", "))
fmt.Println(string(d))
e := []byte{}
e = bytes.Join(c, []byte("--"))
fmt.Println(string(e))
}
Output :
Hello, World!
Hello-- World!
Reference :
Advertisement
Something interesting
Tutorials
+7.3k Golang : Of hash table and hash map
+22.9k Golang : Test file read write permission example
+13.9k Golang : Get current time
+4.9k JQuery : Calling a function inside Jquery(document) block
+5k Google : Block or disable caching of your website content
+20.2k Golang : Compare floating-point numbers
+7.2k Golang : Null and nil value
+9.4k Golang : Play .WAV file from command line
+7.6k Javascript : Push notifications to browser with Push.js
+22.2k Golang : Print leading(padding) zero or spaces in fmt.Printf?
+19.2k Golang : Populate dropdown with html/template example
+11.3k Golang : Post data with url.Values{}