Source File
encoding.go
Belonging Package
runtime/trace
// Copyright 2025 The Go Authors. All rights reserved.// Use of this source code is governed by a BSD-style// license that can be found in the LICENSE file.package traceimport ()// maxVarintLenN is the maximum length of a varint-encoded N-bit integer.const maxVarintLen64 = 10var (errOverflow = errors.New("binary: varint overflows a 64-bit integer")errEOB = errors.New("binary: end of buffer"))// TODO deduplicate this function.func readUvarint( []byte) (uint64, int, error) {var uint64var uintvar bytefor := 0; < maxVarintLen64 && < len(); ++ {= []if < 0x80 {if == maxVarintLen64-1 && > 1 {return , , errOverflow}return | uint64()<<, + 1, nil}|= uint64(&0x7f) <<+= 7}return , len(), errOverflow}// putUvarint encodes a uint64 into buf and returns the number of bytes written.// If the buffer is too small, PutUvarint will panic.// TODO deduplicate this function.func putUvarint( []byte, uint64) int {:= 0for >= 0x80 {[] = byte() | 0x80>>= 7++}[] = byte()return + 1}
![]() |
The pages are generated with Golds v0.7.9-preview. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |