From 364c7d862e95d7c48f96824c531dca80eb693fb4 Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Mon, 21 Jun 2021 17:58:04 +1000 Subject: [PATCH] Add to bencode.Unmarshal doc comment --- bencode/api.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bencode/api.go b/bencode/api.go index 10375c43..80d9951b 100644 --- a/bencode/api.go +++ b/bencode/api.go @@ -127,8 +127,10 @@ func MustMarshal(v interface{}) []byte { return b } -// Unmarshal the bencode value in the 'data' to a value pointed by the 'v' -// pointer, return a non-nil error if any. +// Unmarshal the bencode value in the 'data' to a value pointed by the 'v' pointer, return a non-nil +// error if any. If there are trailing bytes, this results in ErrUnusedTrailingBytes, but the value +// will be valid. It's probably more consistent to use Decoder.Decode if you want to rely on this +// behaviour (inspired by Rust's serde here). func Unmarshal(data []byte, v interface{}) (err error) { buf := bytes.NewReader(data) e := Decoder{r: buf}