This one-liner assigns a string to a slice of bytes:

package main

func main() {

    var s string

    //...

    b := []byte(s)

    //...
}

I found this useful when using ioutil.WriteFile, which accepts a bytes slice as its data parameter:

WriteFile func(filename string, data []byte, perm os.FileMode) error

e.g.:

ioutil.WriteFile(filePath, []byte(content), 0755)