Apply the waring in nbt/README.md

This commit is contained in:
Tnze
2021-06-22 11:18:18 +08:00
parent 4e6349dfda
commit 4f9779df88
4 changed files with 74 additions and 49 deletions

View File

@ -28,13 +28,24 @@ func ExampleMarshal() {
Name string `nbt:"name"`
}{"Tnze"}
var buf bytes.Buffer
if err := Marshal(&buf, value); err != nil {
data, err := Marshal(value)
if err != nil {
panic(err)
}
fmt.Printf("% 02x ", buf.Bytes())
fmt.Printf("% 02x ", data)
// Output:
// 0a 00 00 08 00 04 6e 61 6d 65 00 04 54 6e 7a 65 00
}
func ExampleEncoder_WriteSNBT() {
var buf bytes.Buffer
if err := NewEncoder(&buf).WriteSNBT(`{ name: [Tnze, "Xi_Xi_Mi"]}`); err != nil {
panic(err)
}
fmt.Printf("% 02x ", buf.Bytes())
// Output:
// 0a 00 00 09 00 04 6e 61 6d 65 08 00 00 00 02 00 04 54 6e 7a 65 00 08 58 69 5f 58 69 5f 4d 69 00
}