utils

package
v0.10.3 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2026 License: Apache-2.0 Imports: 13 Imported by: ? 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 utils ...

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AtomicWriteYAML

func AtomicWriteYAML(fs afero.Fs, path string, v any, mode os.FileMode) error

AtomicWriteYAML marshals v as YAML and atomically replaces path on POSIX file systems. It exclusively creates a temporary file in the destination directory with the supplied mode, closes it, then renames it onto path. On failure only that writer's temporary file is removed best-effort.

The parent directory of path is created with mode 0700 if it does not already exist. AtomicWriteYAML does NOT chmod an existing parent dir.

Concurrent saves publish complete snapshots; they do not merge updates.

func ExpandHome

func ExpandHome(path string) (string, error)

ExpandHome resolves a leading "~" to the user's home directory. A bare "~" or "~/..." is expanded; any other path is returned unchanged. A missing HOME (os.UserHomeDir error) yields a wrapped error rather than a panic.

func RedactDSNKeyValues added in v0.10.1

func RedactDSNKeyValues(s string) string

RedactDSNKeyValues scrubs password and sslpassword assignments embedded in connection strings or error text. Backslashes escape the next byte in both quoted and bare values. Unterminated quoted values consume the remainder so an uncertain boundary cannot expose a password suffix.

func ResolveTemplate

func ResolveTemplate(tmpl string, data any) (string, error)

ResolveTemplate executes a text/template against data and returns the result. Caller is responsible for trust boundaries of both 'tmpl' and 'data'. The rendered output MUST NOT be passed unescaped to a shell, SQL driver, or any other interpreter without context-appropriate escaping. text/template provides no command-injection protection. See also: html/template for HTML contexts.

ResolveTemplate never panics: any template parse or execute error is returned as ("", err).

func ScanLinesAndTruncateWhenLongerThanBuffer

func ScanLinesAndTruncateWhenLongerThanBuffer(data []byte, atEOF bool) (advance int, token []byte, err error)

ScanLinesAndTruncateWhenLongerThanBuffer is a bufio.SplitFunc that behaves like bufio.ScanLines but silently truncates any single line longer than constants.MaxLineLength (1 MiB). It is intended for non-UI scan paths where dropping bytes is preferable to bufio.ErrTooLong; UI paths should render their own truncation marker (deferred to E5+).

Types

This section is empty.

Jump to

Keyboard shortcuts

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