util

package
v0.0.0-...-f1cee2f Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2022 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Hostname string

Hostname serves as the default queue name for work queues

Functions

func Canonicalize

func Canonicalize(rawurls ...string) []string

Canonicalize the given URLs

func Decrypt

func Decrypt(ciphertext, pass string) (string, error)

Decrypt decrypts the previously encrypted text using pass

func DecryptJSON

func DecryptJSON(ciphertext, pass string, v interface{}) error

DecryptJSON decrypts to object

func Encrypt

func Encrypt(plaintext, pass string) (string, error)

Encrypt encrypts the given text with the password using AES and SHA256

func EncryptJSON

func EncryptJSON(v interface{}, pass string) (string, error)

EncryptJSON encrypts the given object by serializing to JSON and using Encrypt

func In

func In(s interface{}, val interface{}) bool

In checks if val is in s slice

func Index

func Index(s interface{}, val interface{}) int

Index returns the index for a given value or -1 if not there

func InitLog

func InitLog(fileloc string, logLevel string, stdout bool)

InitLog - init the log for server

func Max

func Max(a int, b int) int

Max returns the max between 2 ints

func Min

func Min(a int, b int) int

Min returns the min between 2 ints

func RandStr

func RandStr(strSize int) string

RandStr returns a random string of size strSize

func SecureRandomString

func SecureRandomString(size int, alphaOnly bool) string

SecureRandomString generate a secure random string of size that can be alpha or alphanum

func SetOutput

func SetOutput(fileloc string)

SetOutput ...

func SplitAndTrim

func SplitAndTrim(s string) []string

SplitAndTrim , split by token "," and trim rach result

func SplitAndTrimByChar

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

SplitAndTrimByChar , split by sep and trim rach result

func Substr

func Substr(s string, from int, to int) string

Substr of string based on runes and not bytes

func ToIntf

func ToIntf(s interface{}) []interface{}

ToIntf converts a slice or array of a specific type to array of interface{}

func ToJSONString

func ToJSONString(in interface{}) string

ToJSONString return a json string representation of the given object for pretty printing

func ToJSONStringNoIndent

func ToJSONStringNoIndent(in interface{}) string

ToJSONStringNoIndent will stringify json into single line without indentation

func ToLower

func ToLower(s []string) []string

ToLower conerts a slice of strings to lower case

Types

type Object

type Object map[string]interface{}

Object generic map to allow JSON nice interactivity

func NewObject

func NewObject(b []byte) (Object, error)

NewObject by parsing the given byte data

func (Object) A

func (o Object) A(path string) []interface{}

A returns given path as []interface{}

func (Object) AStr

func (o Object) AStr(path string) []string

AStr returns given path as []string

func (Object) B

func (o Object) B(path string) bool

B returns given path as bool

func (Object) Get

func (o Object) Get(path string) interface{}

Get a recursive path

func (Object) I

func (o Object) I(path string) int

I returns given path as int

func (Object) O

func (o Object) O(path string) Object

O returns a path as an Object

func (Object) S

func (o Object) S(path string) string

S returns given path as string

func (Object) Stringify

func (o Object) Stringify() string

Stringify the map to JSON string

Jump to

Keyboard shortcuts

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