Documentation ¶
Overview ¶
Package osx is a lightweight extension of the Go 'os' standard package. It provides useful helper and utility functions while minimizing the use of imported third-party dependencies.
Index ¶
- Constants
- func GetEnv(key, fallback string, allowEmptyString bool) string
- func GetEnvBool(key string, fallback bool) bool
- func GetEnvInt(key string, fallback int) (int, bool)
- func GetSudoUID() int
- func GetSudoUser() (*user.User, error)
- func GetSudoUsername() string
- func LookupUID(username string) (int, error)
Constants ¶
const ( AllowNulls = true NoNulls = false )
Optional constants for improving external code readability E.g., osx.GetEnv("KEY", "DEFAULT", osx.AllowNulls) is more readable than osx.GetEnv("KEY", "DEFAULT", false)
Variables ¶
This section is empty.
Functions ¶
func GetEnv ¶
GetEnv reads an environment variable, but allows you to provide a default fallback value and specify if empty string values shall be allowed.
func GetEnvBool ¶ added in v0.0.3
GetEnvBool reads an environment variable and converts it to a boolean, also allowing a default fallback value to be specified
func GetEnvInt ¶
GetEnvInt reads an environment variable and converts it to an integer, also allowing a default fallback value to be specified
func GetSudoUID ¶
func GetSudoUID() int
GetSudoUID returns the UID of the user running the program as sudo. Returns -1 if sudo is not being used. Parameters and return types are consistent with os.Getuid().
func GetSudoUser ¶
GetSudoUser returns the user running the program as sudo. Returns -1 if sudo is not being used. Return types are to retmain consistent with user.Lookup() and user.LookupId().
func GetSudoUsername ¶
func GetSudoUsername() string
GetSudoUsername returns the username of the user running the program as sudo. Returns an empty string if sudo is not being used.
Types ¶
This section is empty.