util

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Base64Decode added in v0.1.21

func Base64Decode(encoded string) (string, error)

Base64Decode decodes 64 encoded string

func Base64Encode added in v0.1.21

func Base64Encode(text string) string

Base64Encode encodes a string

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 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 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 Exec added in v0.1.2

func Exec(command string) (string, string, error)

Exec run a shell command

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 GetVal added in v0.1.10

func GetVal(hash map[string]string, key, def string) string

GetVal gets a value from a hash map

func InArray

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

InArray check if value is on array

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 MergeMaps added in v0.1.10

func MergeMaps(m1, m2 map[string]string) map[string]string

MergeMaps merges two maps

func PathExists

func PathExists(path string) bool

PathExists reports whether the path exists

func Rand added in v0.1.7

func Rand(min, max int) int

Rand gets a random number

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 TimeInSec added in v0.1.11

func TimeInSec(period string) int

TimeInSec time period in seconds

func Unset

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

Unset remove element at position i

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