Standard library / strings

strings.Trim()

Removes leading and trailing runes in cutset; cutset is not a literal substring. Expected stdout: 'go\n'.

Formal Syntax & Structure

go syntaxgo
func Trim(s, cutset string) string

Parameters & Attributes

NameTypeDescription
sstringInput text or sequence.
cutsetstringSet of code points to remove from the indicated ends.

Return Value

string

Removes leading and trailing runes in cutset; cutset is not a literal substring.

Working Example

Example Snippetgo
package main
import (  "fmt"  "strings")
func main() {  fmt.Println(string(strings.Trim("..go.!", ".!")))}
Go Reference