From dac9b9ddbd5160c5f4552410f5f8281bd5eed38c Mon Sep 17 00:00:00 2001 From: Joe Tsai Date: Fri, 1 Sep 2023 01:54:25 -0700 Subject: encoding: modernize Go documentation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Across all encoding packages, linkify declarations if possible. In some cases, we convert a code block into a bulleted list, which then further allows for more linkification. Change-Id: I68fedf362615b34228bab5d4859b7d87d831c570 Reviewed-on: https://go-review.googlesource.com/c/go/+/524977 LUCI-TryBot-Result: Go LUCI Reviewed-by: Daniel Martí Reviewed-by: Ian Lance Taylor Reviewed-by: qiulaidongfeng <2645477756@qq.com> Reviewed-by: Matthew Dempsky --- src/encoding/binary/varint.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/encoding/binary/varint.go') diff --git a/src/encoding/binary/varint.go b/src/encoding/binary/varint.go index 7b14fb2b63..64dd9d61b4 100644 --- a/src/encoding/binary/varint.go +++ b/src/encoding/binary/varint.go @@ -37,7 +37,7 @@ const ( ) // AppendUvarint appends the varint-encoded form of x, -// as generated by PutUvarint, to buf and returns the extended buffer. +// as generated by [PutUvarint], to buf and returns the extended buffer. func AppendUvarint(buf []byte, x uint64) []byte { for x >= 0x80 { buf = append(buf, byte(x)|0x80) @@ -88,7 +88,7 @@ func Uvarint(buf []byte) (uint64, int) { } // AppendVarint appends the varint-encoded form of x, -// as generated by PutVarint, to buf and returns the extended buffer. +// as generated by [PutVarint], to buf and returns the extended buffer. func AppendVarint(buf []byte, x int64) []byte { ux := uint64(x) << 1 if x < 0 { @@ -126,9 +126,9 @@ func Varint(buf []byte) (int64, int) { var errOverflow = errors.New("binary: varint overflows a 64-bit integer") // ReadUvarint reads an encoded unsigned integer from r and returns it as a uint64. -// The error is EOF only if no bytes were read. -// If an EOF happens after reading some but not all the bytes, -// ReadUvarint returns io.ErrUnexpectedEOF. +// The error is [io.EOF] only if no bytes were read. +// If an [io.EOF] happens after reading some but not all the bytes, +// ReadUvarint returns [io.ErrUnexpectedEOF]. func ReadUvarint(r io.ByteReader) (uint64, error) { var x uint64 var s uint @@ -153,9 +153,9 @@ func ReadUvarint(r io.ByteReader) (uint64, error) { } // ReadVarint reads an encoded signed integer from r and returns it as an int64. -// The error is EOF only if no bytes were read. -// If an EOF happens after reading some but not all the bytes, -// ReadVarint returns io.ErrUnexpectedEOF. +// The error is [io.EOF] only if no bytes were read. +// If an [io.EOF] happens after reading some but not all the bytes, +// ReadVarint returns [io.ErrUnexpectedEOF]. func ReadVarint(r io.ByteReader) (int64, error) { ux, err := ReadUvarint(r) // ok to continue in presence of error x := int64(ux >> 1) -- cgit v1.3-5-g45d5