Standard library / bytes
bytes.TrimSpace()
Removes leading and trailing Unicode whitespace, not internal whitespace. The returned slice may alias the input. Expected stdout: 'سلام\n'.
Formal Syntax & Structure
go syntaxgo
func TrimSpace(s []byte) []byteParameters & Attributes
| Name | Type | Description |
|---|---|---|
| s | []byte | Input text or sequence. |
Return Value
[]byte
Removes leading and trailing Unicode whitespace, not internal whitespace. The returned slice may alias the input.
Working Example
Example Snippetgo
package main
import ( "bytes" "fmt")
func main() { fmt.Println(string(bytes.TrimSpace([]byte(" سلام "))))}