To remove whitespaces from a string, we can use strings.TrimSpacearrow-up-right function. It would remove leading and trailing spaces from the string.
strings.TrimSpace
myString := strings.TrimSpace(" Hello World! ") // "Hello World!"
Source: YourBasicarrow-up-right
Last updated 1 year ago