osx

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2020 License: MIT Imports: 4 Imported by: 0

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

View Source
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

func GetEnv(key, fallback string, allowEmptyString bool) string

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

func GetEnvBool(key string, fallback bool) bool

GetEnvBool reads an environment variable and converts it to a boolean, also allowing a default fallback value to be specified

func GetEnvInt

func GetEnvInt(key string, fallback int) (int, bool)

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

func GetSudoUser() (*user.User, error)

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.

func LookupUID

func LookupUID(username string) (int, error)

LookupUID determines the UID of a given username

Types

This section is empty.

Jump to

Keyboard shortcuts

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