Documentation
¶
Overview ¶
Package utils provides helper functions for working with files, directories and strings that are shared across the proxsave codebase.
Index ¶
- func AbsPath(path string) (string, error)
- func ComputeSHA256(filePath string) (string, error)
- func DirExists(path string) bool
- func EnsureDir(path string) error
- func FileExists(path string) bool
- func FindClosingQuoteIndex(s string, quote byte) int
- func FindInlineCommentIndex(line string) int
- func FormatBytes(bytes int64) string
- func GenerateRandomString(length int) string
- func GetFileSize(filePath string) (int64, error)
- func IsAbsPath(path string) bool
- func IsComment(line string) bool
- func ParseBool(s string) bool
- func SetEnvValue(template, key, value string) string
- func SplitKeyValue(line string) (string, string, bool)
- func TrimQuotes(s string) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ComputeSHA256 ¶
ComputeSHA256 computes the SHA256 checksum of a file.
func FindClosingQuoteIndex ¶ added in v0.13.2
FindClosingQuoteIndex returns the index of the closing quote in s, honoring backslash escapes. Assumes s[0] is the opening quote.
func FindInlineCommentIndex ¶ added in v0.13.2
FindInlineCommentIndex returns the index of a # that starts an inline comment. A # inside quotes or escaped with a backslash is ignored.
func FormatBytes ¶
FormatBytes converts bytes to a human-readable format (KB, MB, GB, etc.).
func GenerateRandomString ¶
GenerateRandomString generates a random string of the specified length
func GetFileSize ¶
GetFileSize returns the file size in bytes.
func SetEnvValue ¶ added in v0.13.2
SetEnvValue sets or updates a KEY=VALUE line in a template, preserving indentation and comments.
func SplitKeyValue ¶
SplitKeyValue splits a "key=value" string into key and value. Supports inline comments too: KEY="value" # comment
func TrimQuotes ¶
TrimQuotes removes surrounding quotes from a string.
Types ¶
This section is empty.