How to use strconv.Quote() Function in Golang?
Go language provides inbuilt support to implement conversions to and from string representations of basic data types by strconv Package. This package provides a Quote() function which is used to find a double-quoted Go string literal representing str and the returned string uses Go escape sequences (\t, \n, \xFF, \u0100) to control characters and non-printable characters defined by IsPrint. To access Quote() function you need to import strconv Package in your program.
func Quote(str string) string
Parameter: This function takes one parameter of string type, i.e., str.
Return Value: This function returns a double-quoted Go string literal which represents str.
"\" Hello \n Welcome to GeeksforGeeks \""
Result 1: "\"Hello! GFG \"" Length 1: 19 Result 2: "\"Welcome!\n GeeksforGeeks\"" Length 2: 37
My Personal Notes arrow_drop_up
Please Login to comment...