Skip to content

Commit 25cc452

Browse files
committed
Update example
1 parent 4dfa1d2 commit 25cc452

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

examples/basic/binaries/using_hexdumper.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ func UsingHexDumper() error {
1616
// 実行した場合のような16進数ダンプを出力することができる.
1717
//
1818
// hex.Dumper は、io.Writer を受け取り、io.WriteCloserを返す.
19+
//
20+
// 最後に Close を呼ばないと、ダンプ出力の右側に元の値が表示されないので注意
21+
// (Close を呼ばないままだと、16進部分のみが出力される)
1922
// -----------------------------------------------------
2023
var (
2124
s string = "hello world"
@@ -24,6 +27,11 @@ func UsingHexDumper() error {
2427
dumper io.WriteCloser = hex.Dumper(w)
2528
)
2629

30+
defer func() {
31+
// Close を呼ぶことにより、出力の右側に値が出力される
32+
_ = dumper.Close()
33+
}()
34+
2735
output.Stdoutl("[original]", s)
2836

2937
_, err := io.Copy(dumper, r)

0 commit comments

Comments
 (0)