Here, bytes.ToLower() function is used to convert byte slice to lower case in go. It returns the copy of slice of bytes in lower case.
ToLower() built-in function of bytes package converts slice of bytes with all Unicode letters mapped to their lower case.
bytes.ToLower() function prototype:
func ToLower(s []byte) []byte Input parameters: s: slice of bytes Return: It returns the copy of slice of bytes in lower case.
Explanation on how to convert byte slice to lower case in go
1) s := []byte("TechieIndoor") Output: techieindoor 2) s := []byte("HELLO") Output: hello 3) s := []byte{10, 20} Output: {10, 20}
Example:
Code 1:
package main import ( "bytes" "fmt" ) // main function func main() { s := []byte("TechieIndoor") fmt.Printf("%q", bytes.ToLower(s)) s = []byte("HELLO") fmt.Printf("\n%q", bytes.ToLower(s)) }
Output:
"techieindoor" "hello"
To learn more about golang, Please refer given below link:
References: