utils

package
v0.0.0-...-c1607c5 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AttachConsole

func AttachConsole() error

AttachConsole gives us access to the parent console on Windows, when built as a GUI application, where the console would otherwise not be available.

func CompareSemVer

func CompareSemVer(oldVer, newVer string) int

CompareSemVer returns 1 if the semantic version `newVer` is greater than `oldVer` and -1 otherwise. A semantic version is one that follows the format "1.2.3". If either oldVer or newVer startss with the letter "v", it will be stripped before comparison, along with any hyphenenated (-) suffix. (e.g: "v0.1-alpha" becomes "0.1")

func DownloadWriter

func DownloadWriter(URL string, w io.Writer) error

DownloadWriter retrieves a file from a given URL, and writes the returned contents into the given writer, making sure a status 200 OK was returned.

func FindDirectoriesBySuffix

func FindDirectoriesBySuffix(root, suffix string, ignoreAccessErrors bool) (results []string, err error)

FindDirectoriesBySuffix searches the given root recursively and returns all paths where the last directory component has the supplied suffix, optionally ignoring errors "access denied" and "permission denied"

func FixRedirection

func FixRedirection() error

FixRedirection restores the parent console's ability to redirect this program's output through a pipe to a file or device, where without doing so, the output would be forced to the console even if redirected.

func FreeConsole

func FreeConsole() error

FreeConsole would relinquish our control of the parent console on Windows ? but is it actually necessary ? requires more testing TODO: NOT YET IMPLEMENTED

func SplitFilepath

func SplitFilepath(name string) (fpath, fname, ext string)

SplitFilepath takes a relative or absolute path to a file, and returns the separated path, filename, and file extension. If an extension is present, it will start with a dot character, otherwise it will be an empty string.

func StripPathParts

func StripPathParts(path string, stripRight int) string

StripPathParts takes a given filepath and removes the specified number of path parts; if stripRight is positive, they are removed from the right (end), if negative, they are removed from the left (beginning).

Types

This section is empty.

Jump to

Keyboard shortcuts

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