system

package
v0.21.0 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MaxRepositoryFileBytes is the maximum size of one repository-controlled
	// file parsed in process. The limit is deliberately large enough for
	// monorepo lockfiles while preventing an unbounded allocation.
	MaxRepositoryFileBytes int64 = 64 << 20

	// MaxCacheEntryBytes is the maximum size of one local JSON cache entry.
	// Oversized entries are treated as cache misses by cache callers.
	MaxCacheEntryBytes int64 = 64 << 20
)

Variables

View Source
var ErrInputTooLarge = errors.New("input too large")

ErrInputTooLarge reports that input exceeds a caller-provided size limit.

Functions

func Abs

func Abs(path string) (string, error)

Abs resolves a path to an absolute path.

func ByteLimitLabel added in v0.20.2

func ByteLimitLabel(size int64) string

ByteLimitLabel formats a byte limit for user-facing messages.

func Command

func Command(name string, args ...string) *exec.Cmd

Command constructs an external process command.

func CommandContext added in v0.15.2

func CommandContext(ctx context.Context, name string, args ...string) *exec.Cmd

CommandContext constructs an external process command bound to ctx.

func FileExists

func FileExists(path string) (bool, error)

FileExists reports whether path exists and is a file.

func Getwd

func Getwd() (string, error)

Getwd returns the current working directory.

func LookPath

func LookPath(file string) (string, error)

LookPath resolves a command on PATH.

func OpenFileLimit added in v0.21.0

func OpenFileLimit(path string, maxBytes int64) (io.ReadCloser, error)

OpenFileLimit opens path for streaming reads and enforces maxBytes before opening and while the stream is consumed.

func OpenRepositoryFile added in v0.21.0

func OpenRepositoryFile(path string) (io.ReadCloser, error)

OpenRepositoryFile opens one repository-controlled parser input for a streaming read with the shared repository file limit.

func PathEnv

func PathEnv() string

PathEnv returns the current PATH value.

func ReadCacheFile added in v0.21.0

func ReadCacheFile(path string) ([]byte, error)

ReadCacheFile reads one local cache entry with the shared cache entry limit.

func ReadFileLimit added in v0.20.2

func ReadFileLimit(path string, maxBytes int64) ([]byte, error)

ReadFileLimit reads at most maxBytes from path.

The size is checked before reading when it is available and again while reading, so the limit also holds if the file grows after it is opened.

func ReadLimit added in v0.20.2

func ReadLimit(input io.Reader, declaredSize, maxBytes int64) ([]byte, error)

ReadLimit reads input while enforcing maxBytes. A negative declaredSize means the size is not known before reading.

func ReadRepositoryFile added in v0.21.0

func ReadRepositoryFile(path string) ([]byte, error)

ReadRepositoryFile reads one repository-controlled parser input with the shared repository file limit.

func ResolveExistingFile

func ResolveExistingFile(pathValue string) (string, error)

ResolveExistingFile resolves pathValue to an absolute path and validates that it exists as a file.

func UserHomeDir

func UserHomeDir() (string, error)

UserHomeDir returns the current user's home directory.

Types

This section is empty.

Jump to

Keyboard shortcuts

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