golang/go

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

Open

#49.603 aperta il 16 nov 2021

Vedi su GitHub
 (3 commenti) (0 reazioni) (0 assegnatari)Go (19.008 fork)batch import
DocumentationNeedsFixhelp wanted

Metriche repository

Star
 (133.883 star)
Metriche merge PR
 (Nessuna PR mergiata in 30 g)

Descrizione

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.

Guida contributor