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

@ -1,6 +1,7 @@
package nbt
import (
"bytes"
"errors"
"fmt"
"io"
@ -10,8 +11,10 @@ import (
"strings"
)
func Marshal(w io.Writer, v interface{}, optionalTagName ...string) error {
return NewEncoder(w).Encode(v, optionalTagName...)
func Marshal(v interface{}, optionalTagName ...string) ([]byte, error) {
var buf bytes.Buffer
err := NewEncoder(&buf).Encode(v, optionalTagName...)
return buf.Bytes(), err
}
type Encoder struct {