budget

package
v1.18.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 22, 2026 License: MIT Imports: 1 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package budget contains helpers for memory budget accounting.

Index

Constants

This section is empty.

Variables

View Source
var ErrExceeded = errors.New("memory budget exceeded")

ErrExceeded is returned when an operation would exceed the memory budget.

Functions

func Concat

func Concat(a, b int) uint

Concat returns the memory cost of concatenating strings of lengths a and b. The result of a + b grows the largest of them by the size of the smallest.

func StringGrowth

func StringGrowth(n int, in any) uint

StringGrowth returns the memory cost of a string of length n produced from the input value in.

Strings are immutable, so the inputs of an operation already exist in memory: they are either part of the environment or were already accounted for. The cost is therefore the number of bytes by which the result exceeds its input. Scalar inputs (numbers, bools, etc.) produce strings of bounded size and cost nothing. Any other input (arrays, maps, structs) may reference the same string many times, so the whole result is charged.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL