aboutsummaryrefslogtreecommitdiff
path: root/src/encoding/binary/varint.go
diff options
context:
space:
mode:
authorJoe Tsai <joetsai@digital-static.net>2023-09-01 01:54:25 -0700
committerJoseph Tsai <joetsai@digital-static.net>2023-09-08 19:04:28 +0000
commitdac9b9ddbd5160c5f4552410f5f8281bd5eed38c (patch)
tree63c2331085cdd08681cc2a8d1a30e5b513989ab5 /src/encoding/binary/varint.go
parent45d3d10071830052b45a3299c26a1849a0c0c856 (diff)
downloadgo-dac9b9ddbd5160c5f4552410f5f8281bd5eed38c.tar.xz
encoding: modernize Go documentation
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 <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Daniel Martí <mvdan@mvdan.cc> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: qiulaidongfeng <2645477756@qq.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Diffstat (limited to 'src/encoding/binary/varint.go')
-rw-r--r--src/encoding/binary/varint.go16
1 files changed, 8 insertions, 8 deletions
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)