Standard library / bytes
bytes.Trim()
Removes leading and trailing runes in cutset; cutset is not a literal substring. The returned slice may alias the input. Expected stdout: 'go\n'.
Formal Syntax & Structure
go syntaxgo
func Trim(s []byte, cutset string) []byteParameters & Attributes
| Name | Type | Description |
|---|---|---|
| s | []byte | Input text or sequence. |
| cutset | string | Set of code points to remove from the indicated ends. |
Return Value
[]byte
Removes leading and trailing runes in cutset; cutset is not a literal substring. The returned slice may alias the input.
Working Example
Example Snippetgo
package main
import ( "bytes" "fmt")
func main() { fmt.Println(string(bytes.Trim([]byte("..go.!"), ".!")))}