Documentation
¶
Index ¶
- Constants
- Variables
- func Abs(path string) (string, error)
- func ByteLimitLabel(size int64) string
- func Command(name string, args ...string) *exec.Cmd
- func CommandContext(ctx context.Context, name string, args ...string) *exec.Cmd
- func FileExists(path string) (bool, error)
- func Getwd() (string, error)
- func LookPath(file string) (string, error)
- func OpenFileLimit(path string, maxBytes int64) (io.ReadCloser, error)
- func OpenRepositoryFile(path string) (io.ReadCloser, error)
- func PathEnv() string
- func ReadCacheFile(path string) ([]byte, error)
- func ReadFileLimit(path string, maxBytes int64) ([]byte, error)
- func ReadLimit(input io.Reader, declaredSize, maxBytes int64) ([]byte, error)
- func ReadRepositoryFile(path string) ([]byte, error)
- func ResolveExistingFile(pathValue string) (string, error)
- func UserHomeDir() (string, error)
Constants ¶
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 ¶
var ErrInputTooLarge = errors.New("input too large")
ErrInputTooLarge reports that input exceeds a caller-provided size limit.
Functions ¶
func ByteLimitLabel ¶ added in v0.20.2
ByteLimitLabel formats a byte limit for user-facing messages.
func CommandContext ¶ added in v0.15.2
CommandContext constructs an external process command bound to ctx.
func FileExists ¶
FileExists reports whether path exists and is a file.
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 ReadCacheFile ¶ added in v0.21.0
ReadCacheFile reads one local cache entry with the shared cache entry limit.
func ReadFileLimit ¶ added in v0.20.2
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
ReadLimit reads input while enforcing maxBytes. A negative declaredSize means the size is not known before reading.
func ReadRepositoryFile ¶ added in v0.21.0
ReadRepositoryFile reads one repository-controlled parser input with the shared repository file limit.
func ResolveExistingFile ¶
ResolveExistingFile resolves pathValue to an absolute path and validates that it exists as a file.
func UserHomeDir ¶
UserHomeDir returns the current user's home directory.
Types ¶
This section is empty.