extensions

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2022 License: MIT Imports: 25 Imported by: 16

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Between

func Between(value string, a string, b string) string

Between will return substring between two strings

func BigEndianUInt16

func BigEndianUInt16(value uint16) (value1 byte, value2 byte)

BigEndianUInt16 will convert a uint16 to 2 bytes

func BigEndianUInt32

func BigEndianUInt32(value uint32) (value1 byte, value2 byte, value3 byte, value4 byte)

BigEndianUInt32 will convert a uint32 to 4 bytes

func BoolToString

func BoolToString(val bool) string

func CopyFile

func CopyFile(source string, dest string) (err error)

func CopyFolder

func CopyFolder(source string, dest string) (err error)

func DWordToInt

func DWordToInt(data []byte) (num int32)

DWordToInt converts an 4 byte to a int32

func DirSize

func DirSize(path string) (int64, error)

func DirSizeWithSearch

func DirSizeWithSearch(path string, fileSearch string) (int64, error)

func DoesFileExist

func DoesFileExist(path string) bool

func DoesFileNotExist

func DoesFileNotExist(path string) bool

func ExtractArgsWithinBrackets

func ExtractArgsWithinBrackets(str string) (res []string)

func FloatToString

func FloatToString(input_num float64, precision int) string

func GenPackageImport

func GenPackageImport(name string, imports []string) string

func GetAllDirWithExclude

func GetAllDirWithExclude(path string, except string) (files []os.FileInfo, err error)

func GetAllDirs

func GetAllDirs(path string) (files []os.FileInfo, err error)

func GetAllFiles

func GetAllFiles(path string) (files []os.FileInfo, err error)

func GetAllFilesDeepWithSearch

func GetAllFilesDeepWithSearch(path string, fileSearch string) (files []os.FileInfo, err error)

func GetAllFilesSortedBy

func GetAllFilesSortedBy(path string, fileSearch string) (files []os.FileInfo, err error)

func GetAllFilesWithSearch

func GetAllFilesWithSearch(path string, fileSearch string) (files []os.FileInfo, err error)

func GetAllFolders

func GetAllFolders(path string) (files []os.FileInfo, err error)

func GetAllFoldersWithSearch

func GetAllFoldersWithSearch(path string, fileSearch string) (files []os.FileInfo, err error)

func GetDecimalAndStringFromHex

func GetDecimalAndStringFromHex(twoDigitHexCode string) (decimalValue int, asciiString string, err error)

func GetFileSize

func GetFileSize(path string) (size int64, err error)

func GetUserAgentName

func GetUserAgentName(req *http.Request) (name string)

GetUserAgentName will return the name of the user agent.

func Gzipfunc

func Gzipfunc(source string, target string) (err error)

func HexToInt

func HexToInt(hexStr string) int

func Int32ToDWORD

func Int32ToDWORD(val int32) (value []byte)

Int32ToDWORD converts an int32 to DWORD byte array.

func Int32ToInt

func Int32ToInt(val int32) (ret int)

func Int32ToString

func Int32ToString(val int32) string

func Int64ToInt32

func Int64ToInt32(val int64) (ret int)

func Int64ToString

func Int64ToString(val int64) string

func IntToBool

func IntToBool(val int) bool

func IntToString

func IntToString(val int) string

func IpAddressToUint32

func IpAddressToUint32(ip string) (value uint32)

IpAddressToUint32 will convert a string ip address to UInt32

func IsPrintable

func IsPrintable(s string) bool

func LeftPad

func LeftPad(s string, padStr string, pLen int) string

* leftPad and rightPad just repoeat the padStr the indicated * number of times *

func LeftPad2Len

func LeftPad2Len(s string, padStr string, overallLen int) string

func MD5

func MD5(path string) (string, error)

func MakeFirstLowerCase

func MakeFirstLowerCase(s string) string

func NewUUID

func NewUUID() (string, error)

NewUUID generates a random UUID according to RFC 4122

func ParseAndWriteFile

func ParseAndWriteFile(path string, v interface{}, perm os.FileMode) (err error)

func PrintKiloBytes

func PrintKiloBytes(bytes int64) string

func PrintMegaBytes

func PrintMegaBytes(bytes int64) string

func PrintZettaBytes

func PrintZettaBytes(bytes int64) string

func Random

func Random(min, max int) int

func RandomString

func RandomString(strlen int) string

RandomString returns a random string of length

func ReadFile

func ReadFile(path string) ([]byte, error)

func ReadFileAndParse

func ReadFileAndParse(path string, v interface{}) (err error)

func RemoveDirectory

func RemoveDirectory(dir string) error

func RemoveDirectoryShell

func RemoveDirectoryShell(dir string) (err error)

func RightPad

func RightPad(s string, padStr string, pLen int) string

func RightPad2Len

func RightPad2Len(s string, padStr string, overallLen int) string
the Pad2Len functions are generally assumed to be padded with short sequences of strings

* in many cases with a single character sequence * * so we assume we can build the string out as if the char seq is 1 char and then * just substr the string if it is longer than needed * * this means we are wasting some cpu and memory work * but this always get us to want we want it to be * * in short not optimized to for massive string work * * If the overallLen is shorter than the original string length * the string will be shortened to this length (substr) *

func Round

func Round(x, unit float64) float64

func StringToBool

func StringToBool(val string) bool

func StringToFloat

func StringToFloat(val string, precision int) (r float64)

func StringToInt

func StringToInt(val string) int

func StringToUInt16

func StringToUInt16(val string) uint16

func StringToUInt64

func StringToUInt64(val string) uint64

func StringToUInt8

func StringToUInt8(val string) uint8

func SyncMapAny

func SyncMapAny(x *sync.Map) (ok bool)

SyncMapAny will return true if there are any items in the sync.Map

func SyncMapLength

func SyncMapLength(x *sync.Map) (length int)

SyncMapLength will return true the length of items in the sync.Map

func Tar

func Tar(source string, target string) error

Tar takes a source and variable writers and walks 'source' writing each file found to the tar writer; the purpose for accepting multiple writers is to allow for multiple outputs (for example a file, or md5 hash)

func TrimSuffix

func TrimSuffix(s, suffix string) string

func UnGzipfunc

func UnGzipfunc(source, target string) error

func UnTar

func UnTar(tarball, target string) error

func WriteAndGoFmt

func WriteAndGoFmt(value string, path string, quiet bool, perm os.FileMode) error

func WriteAndGoFormat

func WriteAndGoFormat(value string, path string) error

func WriteToFile

func WriteToFile(value string, path string, perm os.FileMode) error

Types

type ByOldestFile

type ByOldestFile []os.FileInfo

func (ByOldestFile) Len

func (a ByOldestFile) Len() int

func (ByOldestFile) Less

func (a ByOldestFile) Less(i, j int) bool

func (ByOldestFile) Swap

func (a ByOldestFile) Swap(i, j int)

type FilePath

type FilePath struct {
	Name string `json:"Name"`
	Path string `json:"Path"`
	Type string `json:"Type"`
}

func GetAllFilesSearchWithPath

func GetAllFilesSearchWithPath(path string, fileSearch string) (files []FilePath, err error)

func (*FilePath) ToString

func (obj *FilePath) ToString() (str string)

type Version

type Version struct {
	Major          int
	Minor          int
	Revision       int
	MajorString    string
	MinorString    string
	RevisionString string
	Value          string
}

func (*Version) Init

func (obj *Version) Init(value string)

Jump to

Keyboard shortcuts

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