Bytes, bufio and flate - what am I doing wrong?

Hi All,

Go is new to me… This code supposes to log non-empty value representing the bytes of the string. Why does it log an empty string?

var b bytes.Buffer
bufioW := bufio.NewWriter(&b)
flateW, err := flate.NewWriter(bufioW, flate.NoCompression)
flateW.Write([]byte("This is a test"))
flateW.Close()
log.Println("SAML Request after compression: ", b.Bytes())

Thanks,
Yossi

Hi @Yossi.Cohen,

If you call bufioW.Flush() before your log statement, it should work :slight_smile:

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.