Which is the effective way to trim the leading and trailing white spaces of string variable in Go?
Just as @Kabeer has mentioned, you can use TrimSpace and here is an example from golang documentation:
package main import ( "fmt" "strings" ) func main() { fmt.Println(strings.TrimSpace(" \t\n Hello, Gophers \n\t\r\n")) }