Documentation ¶
Index ¶
- Constants
- Variables
- func AtoiNoOct(s string) (int, error)
- func AtoiNoOctTry(s string) (int, bool)
- func CIdentifier(s string) string
- func CallInDir(path string, execFunc func() error) error
- func ChildDirs(path string) ([]string, error)
- func CopyDir(srcDirStr, dstDirStr string) error
- func CopyFile(srcFile string, dstFile string) error
- func DirsAreEqual(dira string, dirb string) (bool, error)
- func EnvVarsToSlice(env map[string]string) []string
- func EnvironAsMap() (map[string]string, error)
- func ErrorMessage(level int, message string, args ...interface{})
- func FileContains(contents []byte, path string) (bool, error)
- func FileContentsChanged(path string, newContents []byte) (bool, error)
- func FileModificationTime(path string) (time.Time, error)
- func FilenameFromPath(s string) string
- func Init(logLevel log.Level, logFile string, verbosity int) error
- func IntMax(a, b int) int
- func IntMin(a, b int) int
- func IsExit(err error) bool
- func IsNotExist(err error) bool
- func LogShellCmd(cmdStrs []string, env map[string]string)
- func MarshalJSONStringer(sr fmt.Stringer) ([]byte, error)
- func Max(x, y int) int
- func Min(x, y int) int
- func MoveDir(srcDir string, destDir string) error
- func MoveFile(srcFile string, destFile string) error
- func NodeExist(path string) bool
- func NodeNotExist(path string) bool
- func OneTimeWarning(text string, args ...interface{})
- func OneTimeWarningError(err error)
- func ParseEqualsPair(v string) (string, string, error)
- func PrintStacks()
- func ReadLines(path string) ([]string, error)
- func ShellCommand(cmdStrs []string, env map[string]string) ([]byte, error)
- func ShellCommandLimitDbgOutput(cmdStrs []string, env map[string]string, logCmd bool, maxDbgOutputChrs int) ([]byte, error)
- func ShellInteractiveCommand(cmdStr []string, env map[string]string, flagBlock bool) error
- func SliceContains(slice interface{}, elem interface{}) bool
- func SliceToEnvVars(slc []string) (map[string]string, error)
- func SortFields(wsSepStrings ...string) []string
- func StatusMessage(level int, message string, args ...interface{})
- func StringMapStringToItfMapItf(sms map[string]string) map[interface{}]interface{}
- func TryRelPath(full string) string
- func UniqueStrings(elems []string) []string
- func WriteMessage(f *os.File, level int, message string, args ...interface{})
- type FileInfo
- type NewtError
- func ChildNewtError(parent error) *NewtError
- func FmtChildNewtError(parent error, format string, args ...interface{}) *NewtError
- func FmtNewtError(format string, args ...interface{}) *NewtError
- func NewNewtError(msg string) *NewtError
- func PreNewtError(err error, format string, args ...interface{}) *NewtError
- type StaticLib
Constants ¶
const ( VERBOSITY_SILENT = 0 VERBOSITY_QUIET = 1 VERBOSITY_DEFAULT = 2 VERBOSITY_VERBOSE = 3 )
Variables ¶
var EscapeShellCmds bool
var ExecuteShell bool
var InjectSyscfg string
var PrintShellCmds bool
var ShallowCloneDepth int
var SkipNewtCompat bool
var SkipSyscfgRepoHash bool
var Verbosity int
Functions ¶
func AtoiNoOct ¶
Converts the specified string to an integer. The string can be in base-10 or base-16. This is equivalent to the "0" base used in the standard conversion functions, except octal is not supported (a leading zero implies decimal).
func AtoiNoOctTry ¶
Converts the specified string to an integer. The string can be in base-10 or base-16. This is equivalent to the "0" base used in the standard conversion functions, except octal is not supported (a leading zero implies decimal).
The second return value is true on success.
func CIdentifier ¶
func DirsAreEqual ¶
DirsAreEqual compares the contents of two directories. Directories are equal if 1) their subdirectory structures are identical, and 2) they contain the exact same set of files (same names and contents).
func EnvVarsToSlice ¶
EnvVarsToSlice converts an environment variable map into a slice of `k=v` strings.
func EnvironAsMap ¶
EnvironAsMap gathers the current process's set of environment variables and returns them as a map.
func ErrorMessage ¶
Print Silent, Quiet and Verbose aware status messages to stderr.
func FileContains ¶
FileContains indicates whether the specified file's contents are equal to the provided byte slice.
func FilenameFromPath ¶
func IsExit ¶
Indicates whether the provided error is of type *exec.ExitError (raised when a child process exits with a non-zero status code).
func IsNotExist ¶
func LogShellCmd ¶
func NodeNotExist ¶
Check whether the node (either dir or file) specified by path exists
func OneTimeWarning ¶
func OneTimeWarning(text string, args ...interface{})
Displays the specified warning if it has not been displayed yet.
func OneTimeWarningError ¶
func OneTimeWarningError(err error)
OneTimeWarningError displays the text of the specified error as a warning if it has not been displayed yet. No-op if nil is passed in.
func PrintStacks ¶
func PrintStacks()
func ReadLines ¶
Reads each line from the specified text file into an array of strings. If a line ends with a backslash, it is concatenated with the following line.
func ShellCommand ¶
Execute the specified process and block until it completes.
@param cmdStrs The "argv" strings of the command to execute. @param env Additional key,value pairs to inject into the
child process's environment. Specify null to just inherit the parent environment.
@return []byte Combined stdout and stderr output of process. @return error NewtError on failure.
func ShellCommandLimitDbgOutput ¶
func ShellCommandLimitDbgOutput( cmdStrs []string, env map[string]string, logCmd bool, maxDbgOutputChrs int) ([]byte, error)
Execute the specified process and block until it completes. Additionally, the amount of combined stdout+stderr output to be logged to the debug log can be restricted to a maximum number of characters.
@param cmdStrs The "argv" strings of the command to execute. @param env Additional key,value pairs to inject into the
child process's environment. Specify null to just inherit the parent environment.
@param logCmd Whether to log the command being executed. @param maxDbgOutputChrs The maximum number of combined stdout+stderr
characters to write to the debug log. Specify -1 for no limit; 0 for no output.
@return []byte Combined stdout and stderr output of process. @return error NewtError on failure. Use IsExit() to
determine if the command failed to execute or if it just returned a non-zero exit status.
func ShellInteractiveCommand ¶
Run interactive shell command
func SliceContains ¶
func SliceContains(slice interface{}, elem interface{}) bool
Function that checks if the slice of any type contains a specified value
func SliceToEnvVars ¶
SliceToEnvVars converts a slice of `k=v` strings into an environment variable map.
func SortFields ¶
Sorts whitespace-delimited lists of strings.
@param wsSepStrings A list of strings; each string contains one or
more whitespace-delimited tokens.
@return A slice containing all the input tokens, sorted
alphabetically.
func StatusMessage ¶
Print Silent, Quiet and Verbose aware status messages to stdout.
func StringMapStringToItfMapItf ¶
StringMapStringToItfMapItf converts a map[string]string to the more generic map[interface{}]interface{} type.
func TryRelPath ¶
Attempts to convert the specified absolute path into a relative path (relative to the current working directory). If the path cannot be converted, it is returned unchanged.
func UniqueStrings ¶
Removes all duplicate strings from the specified array, while preserving order.
Types ¶
type FileInfo ¶
type FileInfo struct { Path string // Path of configuration file. Parent *FileInfo // File that imported this configuration file, if any. }
FileInfo represents a configuration source. It is intended to help the user understand how the system acquired its configuration, and to aid in tracking down errors in configuration files.
func (*FileInfo) ErrTree ¶
ErrTree decorates the given error with a description of the configuration file's import hierarchy. If a configuration error is encountered, this function should be called on the configuration file's *parent*.
func (*FileInfo) ImportString ¶
ImportString creates a string describing the import hierarchy of the given FileInfo. It should be called on the *parent* of the file of interest.
type NewtError ¶
func ChildNewtError ¶
func FmtChildNewtError ¶
func FmtNewtError ¶
func NewNewtError ¶
func PreNewtError ¶
type StaticLib ¶
func NewStaticLib ¶
func UniqueStaticLib ¶
Removes all duplicate static lib from the specified array, while preserving order.