utils

package
v0.0.0-...-dd73c42 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2019 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package utils is a collection of misc tools shared any gourd application

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CborDecoder

func CborDecoder(buffer *[]byte) *codec.Decoder

CborDecoder will decode data from a cbor format

func CborEncoder

func CborEncoder(buffer *[]byte) *codec.Encoder

CborEncoder will encode data in cbor format

func EnvStr

func EnvStr() string

EnvStr returns a human readable form of value for the current environment

func Exec

func Exec(name string, arg ...string) error

Exec provides a thin wrapper over exec.Command

func HomeDir

func HomeDir() string

HomeDir returns the filesystem path to the current user's $HOME directory

func LogDebug

func LogDebug(args ...interface{})

LogDebug logs messages at the debug level

func LogDebugf

func LogDebugf(msg string, args ...interface{})

LogDebugf logs messages at the debug level

func LogError

func LogError(args ...interface{})

LogError logs messages at the error level

func LogErrorf

func LogErrorf(msg string, args ...interface{})

LogErrorf logs messages at the error level

func LogFatal

func LogFatal(args ...interface{})

LogFatal logs messages at the error level

func LogFatalf

func LogFatalf(msg string, args ...interface{})

LogFatalf logs messages at the error level

func LogInfo

func LogInfo(args ...interface{})

LogInfo logs messages at the info level

func LogInfof

func LogInfof(msg string, args ...interface{})

LogInfof logs messages at the info level

func LogTrace

func LogTrace(args ...interface{})

LogTrace logs messages at the trace level

func LogTracef

func LogTracef(msg string, args ...interface{})

LogTracef logs messages at the trace level

func LogWarn

func LogWarn(args ...interface{})

LogWarn logs messages at the warning level

func LogWarnf

func LogWarnf(msg string, args ...interface{})

LogWarnf logs messages at the warning level

func MkdirIfNotExist

func MkdirIfNotExist(dir string)

MkdirIfNotExist is like mkdir -p

func ReadJSON

func ReadJSON(path string, data interface{}) error

ReadJSON decodes JSON formatted data from a path into a data structure

func SetupLogging

func SetupLogging(fn func(*log.Logger, *log.Logger))

SetupLogging is used to configure the primary loggers

func UserCanExec

func UserCanExec(path string) (bool, error)

UserCanExec checks to see if a file can be executed by the current $USER

func Username

func Username() string

Username returns the username of the user that owns the running process

func WriteJSON

func WriteJSON(path string, data interface{}) error

WriteJSON saves a data structure to a path in JSON format

Types

type Env

type Env uint8

Env is an integer that represents a particular Linux distribution

const (
	// UnknownEnv Environment
	UnknownEnv Env = 0
	// DebugEnv is a debugging Environment
	DebugEnv Env = 1
	// DevEnv is a development Environment
	DevEnv Env = 2
	// ProdEnv is a production Environment
	ProdEnv Env = 3
)

func GetEnv

func GetEnv() Env

GetEnv finds the type of runtime environment that is currently active

type FileError

type FileError int

FileError is used to tell the difference between different kind of file errors

const (
	// FENONE means there is no file error
	FENONE FileError = iota
	// FENOEXIST means a file or directory does not exist
	FENOEXIST
	// FEINSFPERM means the active user has insufficient permissions for the
	// requested action on the file
	FEINSFPERM
)

func Exists

func Exists(path string) (bool, FileError)

Exists returns whether the given file or directory exists

type GourdID

type GourdID struct {
	// GID is the system gourd group id
	GID int
	// UID is the system gourd user id
	UID int
}

GourdID holds the system's IDs for the gourd group and user

func GetGourdID

func GetGourdID() (GourdID, error)

GetGourdID returns the IDs for the gourd user and group

type OsInfo

type OsInfo struct {
	KernelName      string `json:"kernel_name"`
	NodeName        string `json:"node_name"`
	KernelRelease   string `json:"kernel_release"`
	Machine         string `json:"machine"`
	OperatingSystem string `json:"operating_system"`
}

OsInfo represents data about the host machine's operating system

func Os

func Os() (OsInfo, error)

Os returns OsInfo about the host machine.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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