In Go language, strings are different from other languages like Java, C++, Python, etc. It is a sequence of variable-width characters where each and every character is represented by one or more bytes using UTF-8 Encoding.
In the Go strings, you are allowed to split the string after the specified separator using a SplitN() function. This function splits a slice into all substrings after each instance of the given separator and returns a slice of the substrings between those separators. The count indicates the number of subslices to return. It is defined under the string package so, you have to import string package in your program for accessing SplitN function.
func SplitN(str, sep string, m int) string
Here, str is the string and sep is the separator. If str does not contain the given sep and sep is non-empty, then it will return a slice of length 1 which contain only str. Or if the sep is empty, then it will split after each UTF-8 sequence. Or if both str and sep are empty, then it will return an empty slice.
Final Result after splitting: Slice 1: [****Welcome to GeeksforGeeks****] Slice 2: [Learning how to x trim x a x slice of bytes] Slice 3:  Slice 4: 
Original Strings: String 1: Welcome, to, Geeks, for, Geeks String 2: AppleAppleAppleAppleAppleApple String 3: %G%E%E%K%sS After splitting: String 1: [Welcome to, Geeks, for, Geeks] String 2: [A leA leAppleAppleAppleApple] String 3: 
- Golang | Splitting the slice after the specified separator
- Golang | Splitting a slice of bytes after the specified separator
- How to split a slice of bytes after the given separator in Golang?
- Golang | Splitting a Slice Separated by the Specified Expression
- How to Trim a String in Golang?
- string package in Golang
- How to Split a String in Golang?
- How to Get the String in Specified Base in Golang?
- How to Reverse a String in Golang?
- string.Contains Function in Golang with Examples
- How to find the last index value of specified string in Golang?
- How to write backslash in Golang string?
- How to Replace Characters in Golang String?
- How to find the index value of specified string in Golang?
- How to check the specified rune in Golang String?
- Golang Program that uses String Switch
- How to convert a string in uppercase in Golang?
- How to fetch an Integer variable as String in GoLang?
- Check if the given characters is present in Golang String
- Golang | Checking the string for the specified regular expression
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. 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.