varutil

package
v0.0.0-...-a532a67 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: LGPL-3.0 Imports: 13 Imported by: 15

Documentation

Index

Constants

View Source
const (
	// ByteMask is mask to filter one byte with '&' and operator
	ByteMask = 0xFF
	// WordMask is mask to filter one word with '&' and operator
	WordMask = 0xFFFF
	// DWordMask is mask to filter one double-word with '&' and operator
	DWordMask = 0xFFFFFFFF
	// LongMask is mask to filter one long with '&' and operator
	LongMask = 0xFFFFFFFFFFFFFFFF

	// ThreeByteMask is mask to filter three bytes with '&' and operator
	ThreeByteMask = 0xFFFFFF
	// FiveByteMask is mask to filter five bytes with '&' and operator
	FiveByteMask = 0xFFFFFFFFFF
	// SixByteMask is mask to filter six bytes with '&' and operator
	SixByteMask = 0xFFFFFFFFFFFF
	// SevenByteMask is mask to filter seven bytes with '&' and operator
	SevenByteMask = 0xFFFFFFFFFFFFFF
)
View Source
const (
	// NumericBytes is set of numeric characters for RandString function
	NumericBytes = "1234567890"
	// LowerAlphaBytes is set of lower alphabetic characters for RandString function
	LowerAlphaBytes = "abcdefghijklmnopqrstuvwxyz"
	// UpperAlphaBytes is set of upper alphabetic characters for RandString function
	UpperAlphaBytes = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
	// AlphaBytes is set of alphabetic characters for RandString function
	AlphaBytes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
	// AlphaNumericBytes is set of numeric and alphabetic characters for RandString function
	AlphaNumericBytes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"
	// LowerAlphaNumericBytes is set of numeric and only lower alphabetic characters for RandString function
	LowerAlphaNumericBytes = "abcdefghijklmnopqrstuvwxyz1234567890"
	// UpperAlphaNumericBytes is set of numeric and only upper alphabetic characters for RandString function
	UpperAlphaNumericBytes = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"
	// StrongBytes is set of numeric, alphabetic and special characters for RandString function
	StrongBytes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*()`~<>?:[]{}-=_+|\\/,."
)

Variables

This section is empty.

Functions

func CleanPath

func CleanPath(p string) (w string)

CleanPath clean path

func FillStruct

func FillStruct(s interface{}, m map[string]interface{}) error

FillStruct load structure data from map

func FixDirPath

func FixDirPath(p *string)

FixDirPath autocorrect dir path to contains / at its end

func FixURL

func FixURL(url *string) error

FixURL fix url to start with http://

func FormatInt

func FormatInt(i *int64, base int) string

FormatInt convert int to string if value is set. Otherwise return "null" string

func FormatIntArray

func FormatIntArray(arr []int64, base int, sep string) string

FormatIntArray transform int array to formatted string

func FullGOPath

func FullGOPath(repourl string) (w string)

FullGOPath return full golang path like host.com/user/repo/dir1/dir2/endpackage for example: github.com/goatcms/goatcore/filesystem/disk If it is not external path return empty string.

func GOPath

func GOPath(repourl string) (w string)

GOPath return golang path like host.com/user/repo for example: github.com/goatcms/goatcore If it is not external path return empty string.

func GetField

func GetField(obj interface{}, name string) (interface{}, error)

GetField return a field value as interface

func HasOneSuffix

func HasOneSuffix(str string, suffixes []string) bool

HasOneSuffix checks any element of array has suffix

func IsArrContainStr

func IsArrContainStr(arr []string, s string) bool

IsArrContainStr checks an array contains an element

func IsWhitespace

func IsWhitespace(s string) bool

IsWhitespace return true if input is white char

func JSONMarshal

func JSONMarshal(v interface{}, unescape bool) ([]byte, error)

JSONMarshal convert object to json (and prepare json to be more user friendly)

func LoadStruct

func LoadStruct(obj interface{}, m map[string]interface{}, tagname string, ignoreUndefined bool) error

LoadStruct load structure data from map. Use name from tag or field name

func ObjectFromJSON

func ObjectFromJSON(object interface{}, data string) error

ObjectFromJSON decode json data to object

func ObjectToJSON

func ObjectToJSON(object interface{}) (string, error)

ObjectToJSON convert object to json

func Quote

func Quote(s *string) string

Quote transform string pointer to quoter string or "null" const (for nil pointer).

func QuoteArray

func QuoteArray(s []string, sep string) string

QuoteArray transform string array to quoter strings

func RandString

func RandString(n int, pool string) string

RandString create new random string

func ReadArguments

func ReadArguments(reader io.Reader) (args []string, eof bool, err error)

ReadArguments convert string to separated arguments array

func ReduceAbsPath

func ReduceAbsPath(path string) (result string, err error)

ReduceAbsPath return shorter path version. Return error if the path refers to a parent directory.

func SetField

func SetField(obj interface{}, name string, value interface{}) error

SetField set a value of struct

func SplitArguments

func SplitArguments(src string) (args []string, eof bool, err error)

SplitArguments convert string to separated arguments array

func SplitWhite

func SplitWhite(s string) ([]string, error)

SplitWhite remove extra spaces

func ToMapInterfaceInterface

func ToMapInterfaceInterface(in map[string]interface{}) (out map[interface{}]interface{})

ToMapInterfaceInterface convert map[string]interface{} to map[interface{}]interface{}

func ToMapStringInterface

func ToMapStringInterface(in map[interface{}]interface{}) (out map[string]interface{})

ToMapStringInterface convert map[interface{}]interface{} to map[string]interface{}

func ToStringArr

func ToStringArr(in []interface{}) (out []string)

ToStringArr convert []interface{} to []string{}

func UnescapeString

func UnescapeString(src string) string

UnescapeString convert '\\' to single '\', '\n' to new line, '\t', '\"' to double quote to tab to new line

Types

This section is empty.

Directories

Path Synopsis
Package plainmap provides primitives for convert types to plainmap.
Package plainmap provides primitives for convert types to plainmap.
r

Jump to

Keyboard shortcuts

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