Go/Packages

[Go] Package strings

llHoYall 2020. 10. 26. 23:21

Package strings implements simple functions to manipulate UTF-8 encoded strings.

Methods

TrimSpace

TrimSpace returns a slice of the string, with all leading and trailing white space removed, as defined by Unicode.

func TrimSpace(s string) string

Usages

package main

import (
  "fmt"
  "strings"
)

func main() {
  greeting := "\n  Hi, nice to meet   you   \t\n"
  fmt.Println(strings.TrimSpace(greeting))
  // Hi, nice to meet   you
}
반응형