golang/go

encoding/binary: Varint signature/docs could benefit from name result parameters

Open

#49,603 opened on 2021年11月16日

GitHub で見る
 (3 comments) (0 reactions) (0 assignees)Go (19,008 forks)batch import
DocumentationNeedsFixhelp wanted

Repository metrics

Stars
 (133,883 stars)
PR merge metrics
 (30d に merged PR はありません)

説明

https://pkg.go.dev/encoding/binary@master#Varint says:

func Varint(buf []byte) (int64, int)

Varint decodes an int64 from buf and returns that value and the number of bytes read (> 0). If an error occurred, the value is 0 and the number of bytes n is <= 0 with the following meaning:

n == 0: buf too small
n  < 0: value larger than 64 bits (overflow)
        and -n is the number of bytes read

--

That signature and docs (referencing n that's never named) are really asking to have named results.

コントリビューターガイド