Skip to content

Commit c79deb2

Browse files
committed
Update
1 parent c4cc35b commit c79deb2

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

examples/basic/fileio/multiwriter/gzip_and_crc.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ func GzipAndCrc() error {
2525
buf = new(bytes.Buffer)
2626
gzipW = gzip.NewWriter(buf)
2727
crcW = crc32.NewIEEE()
28-
writer = io.MultiWriter(gzipW, crcW, hex.Dumper(os.Stdout))
28+
hexW = hex.Dumper(os.Stdout)
29+
writer = io.MultiWriter(gzipW, crcW, hexW)
2930
err error
3031
)
3132
defer gzipW.Close()
@@ -34,8 +35,8 @@ func GzipAndCrc() error {
3435
if err != nil {
3536
return err
3637
}
38+
hexW.Close()
3739

38-
output.Stdoutl("")
3940
output.Stdoutf("[orig]", "%x\n", data)
4041
output.Stdoutf("[gzip]", "%x\n", buf.Bytes())
4142
output.Stdoutf("[crc ]", "%x\n", crcW.Sum32())
@@ -52,13 +53,13 @@ func GzipAndCrc() error {
5253
[Name] "fileio_multiwriter_gzipandcrc"
5354
00000000 68 65 6c 6c 6f 20 77 6f 72 6c 64 20 e3 81 93 e3 |hello world ....|
5455
00000010 82 93 e3 81 ab e3 81 a1 e3 81 af 20 e4 b8 96 e7 |........... ....|
55-
00000020 95 8c
56+
00000020 95 8c |..|
5657
[orig] 68656c6c6f20776f726c6420e38193e38293e381abe381a1e381af20e4b896e7958c
5758
[gzip] 1f8b08000000000000ff
5859
[crc ] 6535a281
5960
6061
61-
[Elapsed] 343.1µs
62+
[Elapsed] 394.39µs
6263
*/
6364

6465
}

0 commit comments

Comments
 (0)