utils

package
v0.18.7 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BytesToGigabytes

func BytesToGigabytes(b uint64) float64

BytesToGigabytes converts bytes to gigabytes and rounds to two decimal places.

func BytesToMegabytes

func BytesToMegabytes(b float64) float64

BytesToMegabytes converts bytes to megabytes and rounds to two decimal places.

func FileExists

func FileExists(path string) bool

FileExists reports whether the given path exists.

func GetEnv

func GetEnv(key string) (value string, exists bool)

GetEnv retrieves an environment variable with a "BESZEL_AGENT_" prefix, or falls back to the unprefixed key.

func LookPathHomebrew

func LookPathHomebrew(file string) (string, error)

LookPathHomebrew is like exec.LookPath but also checks Homebrew paths.

func ReadStringFile

func ReadStringFile(path string) string

ReadStringFile returns trimmed file contents or empty string on error.

func ReadStringFileLimited

func ReadStringFileLimited(path string, maxSize int) (string, error)

ReadStringFileLimited reads a file into a string with a maximum size (in bytes) to avoid allocating large buffers and potential panics with pseudo-files when the size is misreported.

func ReadStringFileOK

func ReadStringFileOK(path string) (string, bool)

ReadStringFileOK returns trimmed file contents and read success.

func ReadUintFile

func ReadUintFile(path string) (uint64, bool)

ReadUintFile parses a decimal uint64 value from a file.

func TwoDecimals

func TwoDecimals(value float64) float64

TwoDecimals rounds a float64 value to two decimal places.

Types

This section is empty.

Jump to

Keyboard shortcuts

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