Skip to content

jimsnab/go-simpleutils

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

simpleutils

import "github.com/jimsnab/go-simpleutils"

Index

func CharGet

func CharGet(input string, position int) rune

Charget returns the rune at the logical index position

func CopyFile(srcPath, destPath string) (int64, error)

CopyFile reads file content into memory and writes it to a new file

func DeepCopy(src interface{}) (dest interface{})

DeepCopy generates a separate copy of a source object

func Escape

func Escape(s string) string

Escape translates control characters to backslash escape sequence; e.g., '\r' becomes `\r`

func FileExists(path string) (bool, error)

FileExists returns true if path corresponds to a file, and false if it corresponds to nothing or to a directory.

func GenerateRandomBytes(count int) ([]byte, error)

GenerateRandomBytes returns a byte array of cryptographic (true) random numbers. The byte array length is specified by count.

func GenerateRandomString(count int) (string, error)

GenerateRandomString returns a base-64 encoding of a cryptographic (true) random number byte array. The byte array length is specified by count.

func IndexAt

func IndexAt(testString, substring string, startingIndex int) int

IndexAt is like strings.Index with a starting index

func IndexAtAny(testString, chars string, startingIndex int) int

IndexAtAny is like strings.Index with a starting index

func IsDirectory(path string) (bool, error)

IsDirectory returns true if path corresponds to a directory, and false if it corresponds to nothing or to a file.

func IsTokenCharFirst(ch rune) bool

IsTokenCharFirst returns true if ch is a letter or underscore

func IsTokenCharNext(ch rune) bool

IsTokenCharNext returns true if ch is a letter, number or underscore

func IsTokenName(s string) bool

IsTokenName returns true if s contains only letters, numbers or underscores, and does not start with a number, and has at least one letter

func IsTokenNameWithMiddleChars(s string, middleChars string) bool

IsTokenNameWithMiddleChars returns true if s contains only letters, numbers or underscores, or has allowed characters that are not first or last, does not start with a number, and has at least one letter. A common middleChars string is "-".

func PatternMatch(pattern string, testString string) bool

PatternMatch performs a simple asterisk-based pattern match

func PrintableStr(input string) string

PrintableStr converts non-printable characters in input to a dot

func RuneIndexAt(testString, substring []rune, startingIndex int) int

RuneIndexAt is a version of IndexAt for rune arrays

func RuneIndexAtAny(testString, chars []rune, startingIndex int) int

RuneIndexAtAny is a version of IndexAtAny for rune arrays

func SortedKeys(m interface{}) []string

SortedKeys returns the key array for the map, sorted A-Z

func StringArrayToString(strs []string, delimiter string) string

StringArrayToStrings converts an array of strings to a single string, placing the delimiter string between each

func Substr

func Substr(input string, start int, length int) string

Substr returns a string based on logical character start and length, instead of bytes like a slice

func Utf8len

func Utf8len(data []byte, offset int) int

Utf8len returns the number of bytes in the logical UTF-8 character, 0 if the character is incomplete, or -1 if the character is invalid,

func WhichSuffix(s string, suffixes ...string) *string

WhichSuffix returns a pointer to the first suffix matching s, or nil if none of the suffixes match

HashedText is a typed alias for string

type HashedText string
func HashText(text string) HashedText

HashText returns a sha1 hash of text in base64 encoding.

Generated by gomarkdoc

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published