]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Add to bencode.Unmarshal doc comment
authorMatt Joiner <anacrolix@gmail.com>
Mon, 21 Jun 2021 07:58:04 +0000 (17:58 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Mon, 21 Jun 2021 07:58:04 +0000 (17:58 +1000)
bencode/api.go

index 10375c434ac79724003c8c3ac39e0307d10f4664..80d9951bc6061654c591cc94896f023a4565debb 100644 (file)
@@ -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}