util

package
v1.2.6 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckPasswordHash

func CheckPasswordHash(password, hash string) bool

CheckPasswordHash validate password with a hash

func ClearDir

func ClearDir(dir string) error

ClearDir removes all files and sub dirs

func ConvertToJSON

func ConvertToJSON(item interface{}) (string, error)

ConvertToJSON convert object to json

func Decrypt

func Decrypt(data []byte, passphrase string) ([]byte, error)

Decrypt decrypts data

func DeleteDir

func DeleteDir(dir string) bool

DeleteDir deletes a dir

func DeleteFile

func DeleteFile(path string) error

DeleteFile deletes a file

func DirExists

func DirExists(path string) bool

DirExists reports whether the dir exists

func Encrypt

func Encrypt(data []byte, passphrase string) ([]byte, error)

Encrypt encrypt data

func EnsureDir

func EnsureDir(dirName string, mode int) (bool, error)

EnsureDir ensures that directory exists

func EnsureTrailingSlash

func EnsureTrailingSlash(dir string) string

EnsureTrailingSlash ensure there is a trailing slash

func FileExists

func FileExists(path string) bool

FileExists reports whether the named file exists

func FilterFiles

func FilterFiles(files, filters []string) []string

FilterFiles filters files list based on specific sub-strings

func GenerateUUID4

func GenerateUUID4() string

GenerateUUID4 create a UUID

func GetHostname

func GetHostname() (string, error)

GetHostname gets the hostname

func HashPassword

func HashPassword(password string) (string, error)

HashPassword hashes the password

func InArray

func InArray(val interface{}, array interface{}) bool

InArray check if value is on array

func IsEmailValid

func IsEmailValid(email string) bool

IsEmailValid checks if the email provided passes the required structure and length test. It also checks the domain has a valid MX record.

func IsEmpty

func IsEmpty(item string) bool

IsEmpty validate if string is empty or not

func LoadFromJSON

func LoadFromJSON(item interface{}, data []byte) error

LoadFromJSON update object from json

func PathExists

func PathExists(path string) bool

PathExists reports whether the path exists

func ReadFile

func ReadFile(path string) (string, error)

ReadFile get the file content

func RemoveStartingSlash

func RemoveStartingSlash(dir string) string

RemoveStartingSlash removes any starting slash

func RemoveTrailingSlash

func RemoveTrailingSlash(dir string) string

RemoveTrailingSlash removes any trailing slash

func StoreFile

func StoreFile(path, content string) error

StoreFile stores a file content

func Unset

func Unset(a []string, i int) []string

Unset remove element at position i

func ValidRelPath

func ValidRelPath(path string) bool

ValidRelPath checks for path traversal and correct forward slashes

Types

type Map

type Map struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Map type

func NewMap

func NewMap() Map

NewMap creates a new instance of Map

func (*Map) Delete

func (cm *Map) Delete(key string)

Delete deletes a key

func (*Map) Get

func (cm *Map) Get(key string) (interface{}, bool)

Get a key from a concurrent map

func (*Map) Set

func (cm *Map) Set(key string, value interface{})

Set a key in a concurrent map

Jump to

Keyboard shortcuts

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