Standard library / net/textproto

textproto.TrimString()

Trim leading and trailing ASCII whitespace; unlike strings.TrimSpace this does not remove all Unicode whitespace. Expected stdout: '"Go"\n'.

Formal Syntax & Structure

go syntaxgo
func TrimString(s string) string

Parameters & Attributes

NameTypeDescription
sstringInput string to process.

Return Value

string

String with leading and trailing ASCII whitespace removed.

Working Example

Example Snippetgo
package main
import (  "fmt"  "net/textproto")
func main() { fmt.Printf("%q\n", textproto.TrimString(" \tGo\r\n")) }
func must[T any](v T, e error) T {  if e != nil {    panic(e)  }  return v}func check(e error) {  if e != nil {    panic(e)  }}
Go Reference
textproto.TrimString() — Go Syntax & Examples | ByteMind