Forgot to do a Flush on bufio.NewWriter, and the Bytes() method was returning an empty slice: var buffer bytes.Buffer writer := bufio.NewWriter(&buffer) ... do something with writer // did not call <b>writer.Flush()</b> data := writer.Bytes()