Go bytes Package Join()
package main//from w w w . j a v a 2s . c om import ( "bytes" "fmt" ) func main() { bytesValue := []byte("this is a test from java2s.com") space := []byte{' '} splitExample := bytes.Split(bytesValue, space) fmt.Printf("\nSplit split %q on a single space:", bytesValue) for index,element := range splitExample{ fmt.Printf("\n%d => %q", index, element) } joinChar := []byte{'-'} bytesJoin := bytes.Join(splitExample,joinChar) fmt.Printf("\n\nJoin joins slice with '-' : %q", bytesJoin) fmt.Printf("\nEqual Checks Byte Slice:%v",bytes.Equal(bytesJoin,bytesValue)) bytesJoin = bytes.Join(splitExample,space) fmt.Printf("\nEqual Checks Byte Slice:%v",bytes.Equal(bytesJoin,bytesValue)) }