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
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