util

package
v0.0.0-...-8112484 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Abs

func Abs(path string) (dir string)

Abs returns an absolute representation of path; Ignores errors.

func AbsBase

func AbsBase(path string) (dir string)

AbsBase returns `filepath.Base(path)` after converting to absolute representation of path; Ignores errors.

func BytesToBase64

func BytesToBase64(input []byte) string

BytesToBase64 gets base-64 StdEncoding

func CacheBytes

func CacheBytes(path string) []byte

CacheBytes Loads a local file in to `[]bytes`.

func CacheFile

func CacheFile(path string) string

CacheFile Loads a local file in to `string`

func Cat

func Cat(pInputString ...string) string

Cat - Concatenate a string by way of writing input to a buffer and converting returning its .WriteString() function.

func CatArray

func CatArray(input []string) string

CatArray - Concatenate a string, or empty string.

func CatArrayPad

func CatArrayPad(pStrArray []string, pad string) string

CatArrayPad - Concatenate a string were padding the buffer here with a single char.

func CatPath

func CatPath(input ...string) string

CatPath concatenates a path-string

func CharIsNumber

func CharIsNumber(input string) bool

CharIsNumber checks wether input string contains all digit characters.

func CheckDateString

func CheckDateString(input string) string

CheckDateString checks the beginning of a file-name for an 8-digit date-string; I.E.: `YYYYMMDD`

func ConvertTransient

func ConvertTransient(pInput string) string

ConvertTransient What does this actually do?

func DirectoryExists

func DirectoryExists(path string) bool

DirectoryExists checks if a given Directory exists.

func FileExists

func FileExists(path string) bool

FileExists checks if a given path or file exists.

func FromBase64

func FromBase64(input string) []byte

FromBase64 gets base-64 StdEncoding; ignores error.

func FromBase64e

func FromBase64e(input string) ([]byte, error)

FromBase64e gets base-64 StdEncoding (with error)

func FromUBase64

func FromUBase64(input string) string

FromUBase64 gets base-64 URLEncoding

func GetDirectory

func GetDirectory(path string) string

GetDirectory expects a file as input and returns its parent directory. if input is a directory, I'm wondering what happens.

WARNING: **THIS FILE RETURNS A EMPTY STRING ON ERROR!** use `filepath.Dir` or `util.GetDirectoryE`!

func GetDirectoryE

func GetDirectoryE(path string) (string, error)

GetDirectoryE expects a file as input and returns its parent directory. if input is a directory, I'm wondering what happens.

func GetMediaFile

func GetMediaFile(path string) (tag.Metadata, error)

func IIF

func IIF(condition bool, onTrue string, onFalse string) string

IIF returns a string depending on the boolean condition, onTrue or onFalse.

func Insert

func Insert(slice []int, index, value int) []int

Insert inserts the value into the slice at the specified index, which must be in range. The slice must have room for the new element.

func IsMediaFile

func IsMediaFile(path string) bool

func MultiReplace

func MultiReplace(input string, replace string, find ...string) string

MultiReplace converts whatever to whatever. This is used to convert, for example, various characters (`find`) to a dash.

func OSSlash

func OSSlash(path string) string

OSSlash converts all backslash to forward-slash (if OS is not windows). It'd probably be best to just use your standard `fileutil.Abs(…)`.

func PathExists

func PathExists(path string) bool

PathExists checks if a given File or Directory exists.

func Sha1String

func Sha1String(pStrData string) string

Sha1String just gets SHA1 StdEncoding.

func Space2Dash

func Space2Dash(text string) string

Space2Dash converts or replaces all spaces in a string with a small-dash.

func StrInt64

func StrInt64(pStrInput string) int64

StrInt64 string to int helper

func StrTransformLiteral

func StrTransformLiteral(text string) (str string)

StrTransformLiteral takes a literal string stuff like `EOL` and asserts literal code(s) such as `\n` and takes a measure or two to clean up the string to something a bit more normative. You might say, this makes a string suitable *from* JSON value ---might not aside from char-codes.

func StripFileExtension

func StripFileExtension(path string) string

StripFileExtension ...yep.

func StripFileExtensionC

func StripFileExtensionC(condition bool, path string) string

StripFileExtensionC ...yep.

func ToBase64

func ToBase64(input string) string

ToBase64 gets base-64 StdEncoding

func ToUBase64

func ToUBase64(input string) string

ToUBase64 gets base-64 URLEncoding

func Touch

func Touch(path string) bool

Touch will create a file if it does not exist returns success. Bare in mind if the file exists before calling, then this will return false.

func Trim

func Trim(separator string, text ...string) []string

Trim trims each text element in the input array. TODO: should we act on `text` itself or return a new value?

func TrimJoin

func TrimJoin(separator string, text ...string) string

TrimJoin trims each text element in the input array and `Join`s the result (using separator). TODO: should we act on `text` itself or return a new value?

func TrimUnixSlash

func TrimUnixSlash(text string) string

TrimUnixSlash trims left and right forward-slashes from input string.

func TrimUnixSlashLeft

func TrimUnixSlashLeft(text string) string

TrimUnixSlashLeft trims leftmost forward-slash from input string.

func TrimUnixSlashRight

func TrimUnixSlashRight(text string) string

TrimUnixSlashRight trims right forward-slash from input string.

func UnixSlash

func UnixSlash(path string) string

UnixSlash converts all backslash to forward-slash.

func WReap

func WReap(separator string, text ...string) string

WReap makes sure that each text node is trimmed of `separator` and also wraps text with the `separator`.

func WReapLeft

func WReapLeft(separator string, text ...string) string

WReapLeft makes sure that each text node is trimmed of `separator` and also left-wraps text with the `separator`.

func WReapRight

func WReapRight(separator string, text ...string) string

WReapRight makes sure that each text node is trimmed of `separator` and also right-wraps text with the `separator`.

func Wrap

func Wrap(wrap string, text string) string

Wrap wraps text with `wrap`, written for converting "v" to "/v/". see: https://blog.golang.org/strings

func WrapLeft

func WrapLeft(separator string, text string) string

WrapLeft puts `wrap` at the beginning of the string if not already present.

func WrapRight

func WrapRight(separator string, text string) string

WrapRight puts `wrap` at the end of the string if not already present.

func Wrapper

func Wrapper(separator string, text ...string) string

Wrapper concatenates text and wraps it like `Wrap` does with `sep`-arator.

func WrapperLeft

func WrapperLeft(separator string, text ...string) string

WrapperLeft concatenates text and wraps it like `Wrap` and pads it to the left with `sep`.

func WrapperRight

func WrapperRight(separator string, text ...string) string

WrapperRight concatenates text and wraps it like `Wrap` and pads it to the right with `sep`.

Types

type FileTime

type FileTime struct {
	CreationTime   time.Time
	LastAccessTime time.Time
	LastWriteTime  time.Time
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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