In Go language slice is more powerful, flexible, convenient than an array, and is a lightweight data structure. The slice is a variable-length sequence which stores elements of a similar type, you are not allowed to store different type of elements in the same slice.
In the Go slice of bytes, you are allowed to join the elements of the byte slice with the help of Join() function. Or in other words, Join function is used to concatenate the elements of the slice and return a new slice of bytes which contain all these joined elements separated by the given separator. It is defined under the bytes package so, you have to import bytes package in your program for accessing Join function.
func Join(slice_1 byte, sep byte) byte
Here, sep is the separator placed between the elements of the resulting slice. Let us discuss this concept with the help of the examples:
First Name: Sumit Middle Name: Kumar Last Name: Singh Full name of the student: Sumit-Kumar-Singh
Slice(Before): Slice 1: [Geeks for Geeks] Slice 2: [Hello My name is Bongo] Slice(after): New Slice_1: Geeks , for , Geeks New Slice_2: Hello * My * name * is * Bongo New Slice_3: Hey+I+am+Apple
- How to copy one slice into another slice in Golang?
- Finding the index value of specified byte in slice of bytes in Golang
- How to find last index value of specified byte in slice of bytes in Golang?
- Golang | Checking the byte of slice for specified regular expression
- How to replace all the elements in slice of bytes in Golang?
- How to convert a slice of bytes in uppercase in Golang?
- How to convert a slice of bytes in lowercase in Golang?
- Check if the given slice is sorted in Golang
- Searching an element of float64 type in Golang slice
- How to pass a Slice to Function in Golang?
- How to Sort a Slice of Strings in Golang?
- Check if the specified element is present in the slice of bytes in Golang
- How to count specific characters present in the slice in Golang?
- How to sort a slice of ints in Golang?
- How to sort a slice of float64s in Golang?
- Checking Slice of bytes for equality under Unicode case folding in Golang
- Check if the Slice of bytes starts with specified prefix in Golang
- Check if the Slice of bytes ends with specified suffix in Golang
- How to replace a specified element in slice of bytes in Golang?
- How to repeat a slice of bytes in Golang?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.