Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Golang trim control characters (NULL) from bytes slice
package main
import (
"bytes"
"fmt"
)
func main() {
b := make([]byte, 100)
b[0] = 'A'
fmt.Println(len(b)) // 100
b = bytes.Trim(b, "\x00")
fmt.Println(len(b)) // 1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.