Create a string with a null byte
Use \x00
package main
import (
"fmt"
)
func main() {
fmt.Println([]byte("\x00"))
}
=> [0]
Escaping 0 will NOT work:
nul := "\0"
=> invalid character '"' in octal escape
Tweet
Use \x00
package main
import (
"fmt"
)
func main() {
fmt.Println([]byte("\x00"))
}
=> [0]
Escaping 0 will NOT work:
nul := "\0"
=> invalid character '"' in octal escape
Tweet