Today I Learned

A Hashrocket project

Ready to join Hashrocket? Find Openings here and apply today.

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