osx

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package osx extends the standard os package: typed environment lookups with defaults (the config-from-env boilerplate every service re-writes) and an atomic WriteFile.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnvBool

func EnvBool(key string, def bool) bool

EnvBool returns the environment variable key parsed with strconv.ParseBool ("1", "t", "true", ... case-insensitively), or def when the variable is unset, empty, or unparsable.

func EnvDuration

func EnvDuration(key string, def time.Duration) time.Duration

EnvDuration returns the environment variable key parsed as a time.Duration, or def when the variable is unset, empty, or unparsable. A bare integer (no unit) is read as SECONDS — env files and Helm charts routinely write "30" where Go wants "30s".

func EnvInt

func EnvInt(key string, def int) int

EnvInt returns the environment variable key parsed as an int, or def when the variable is unset, empty, or unparsable.

func EnvInt64

func EnvInt64(key string, def int64) int64

EnvInt64 returns the environment variable key parsed as an int64, or def when the variable is unset, empty, or unparsable.

func EnvStr

func EnvStr(key, def string) string

EnvStr returns the value of the environment variable key, or def when the variable is unset or empty.

func WriteFileAtomic

func WriteFileAtomic(path string, data []byte, perm os.FileMode) error

WriteFileAtomic writes data to path via a same-directory temp file and rename, so readers never observe a truncated or half-written file — the guarantee os.WriteFile does not give when the writer crashes mid-write. The temp file lives next to path (rename must not cross filesystems). No fsync: this guards against partial writes, not power loss; callers needing power-loss durability should sync the file and directory themselves.

Types

This section is empty.

Jump to

Keyboard shortcuts

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