Standard library / strings

strings.TrimSpace()

Removes leading and trailing Unicode whitespace, not internal whitespace. Expected stdout: 'سلام\n'.

Formal Syntax & Structure

go syntaxgo
func TrimSpace(s string) string

Parameters & Attributes

NameTypeDescription
sstringInput text or sequence.

Return Value

string

Removes leading and trailing Unicode whitespace, not internal whitespace.

Working Example

Example Snippetgo
package main
import (  "fmt"  "strings")
func main() {  fmt.Println(string(strings.TrimSpace("  سلام  ")))}
Go Reference