utils

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2021 License: NCSA Imports: 33 Imported by: 10

README

utils Build Status

Common utility functions

Documentation

Index

Constants

View Source
const (
	Flop  = 1
	KFlop = Flop * 1000
	MFlop = KFlop * 1000
	GFlop = MFlop * 1000
	TFlop = GFlop * 1000
	PFlop = TFlop * 1000
	EFlop = PFlop * 1000
)

Flop Sizes.

View Source
const (
	IP           string = `` /* 659-byte string literal not displayed */
	URLSchema    string = `((ftp|tcp|udp|wss?|https?):\/\/)`
	URLUsername  string = `(\S+(:\S*)?@)`
	Hostname     string = ``
	URLPath      string = `((\/|\?|#)[^\s]*)`
	URLPort      string = `(:(\d{1,5}))`
	URLIP        string = `([1-9]\d?|1\d\d|2[01]\d|22[0-3])(\.(1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.([0-9]\d?|1\d\d|2[0-4]\d|25[0-4]))`
	URLSubdomain string = `((www\.)|([a-zA-Z0-9]([-\.][-\._a-zA-Z0-9]+)*))`
	URL          string = `^` + URLSchema + `?` + URLUsername + `?` + `((` + URLIP + `|(\[` + IP + `\])|(([a-zA-Z0-9]([a-zA-Z0-9-_]+)?[a-zA-Z0-9]([-\.][a-zA-Z0-9]+)*)|(` + URLSubdomain + `?))?(([a-zA-Z\x{00a1}-\x{ffff}0-9]+-?-?)*[a-zA-Z\x{00a1}-\x{ffff}0-9]+)(?:\.([a-zA-Z\x{00a1}-\x{ffff}]{1,}))?))\.?` + URLPort + `?` + URLPath + `?$`
)

Variables

View Source
var (
	KeyLength    = 32
	CryptoHeader = fmt.Sprintf("==AES%d==", KeyLength)
	KeyBuffer    = []byte(strings.Repeat("=", 32))
)
View Source
var MD5Sum = md5sumTy{}
View Source
var SHASum = shasumTy{}

Functions

func Decrypt

func Decrypt(key, text []byte) ([]byte, error)

func DecryptString

func DecryptString(key, text string) (string, error)

func DecryptStringBase64

func DecryptStringBase64(key, text string) (string, error)

func DirSize

func DirSize(path string) (int64, error)

DirSize takes a path and returns its size in bytes

func Encrypt

func Encrypt(key, text []byte) ([]byte, error)

func EncryptString

func EncryptString(key, text string) (string, error)

func EncryptStringBase64

func EncryptStringBase64(key, text string) (string, error)

func Every

func Every(duration time.Duration, f func())

func FileSize

func FileSize(filepath string) (int64, error)

func Flatten2DFloat32

func Flatten2DFloat32(f interface{}) [][]float32

func FlattenBoolSlice

func FlattenBoolSlice(data interface{}) []bool

func FlattenFloat32

func FlattenFloat32(f interface{}) ([]float32, error)

func FlattenFloat32Slice

func FlattenFloat32Slice(data interface{}) []float32

func FlattenFloat64Slice

func FlattenFloat64Slice(data interface{}) []float64

func FlattenInt16Slice

func FlattenInt16Slice(data interface{}) []int16

func FlattenInt32Slice

func FlattenInt32Slice(data interface{}) []int32

func FlattenInt64Slice

func FlattenInt64Slice(data interface{}) []int64

func FlattenInt8Slice

func FlattenInt8Slice(data interface{}) []int8

func FlattenIntSlice

func FlattenIntSlice(data interface{}) []int

func FlattenUint16Slice

func FlattenUint16Slice(data interface{}) []uint16

func FlattenUint32Slice

func FlattenUint32Slice(data interface{}) []uint32

func FlattenUint64Slice

func FlattenUint64Slice(data interface{}) []uint64

func FlattenUint8Slice

func FlattenUint8Slice(data interface{}) []uint8

func FlattenUintSlice

func FlattenUintSlice(data interface{}) []uint

func FlattenUintptrSlice

func FlattenUintptrSlice(data interface{}) []uintptr

func FlattenedLength

func FlattenedLength(val interface{}) (int64, error)

func Flops

func Flops(s uint64) string

Flops produces a human readable representation of an SI size.

Flops(82854982) -> 83 MFlops

func GetExternalIp

func GetExternalIp() (string, error)

func GetFunctionName

func GetFunctionName(i interface{}) string

func GetHostIP

func GetHostIP() string

func GetLocalIP0

func GetLocalIP0() (string, error)

func GetLocalIp

func GetLocalIp() (string, error)

GetLocalIp returns the non loopback local IP of the host

func IsEncrypted

func IsEncrypted(b []byte) bool

func IsEncryptedString

func IsEncryptedString(s string) bool

func RandString

func RandString(strSize int, randType string) string

func ShapeAndTypeOf

func ShapeAndTypeOf(val interface{}) (shape []int64, dt reflect.Type, err error)

Types

type ElementType

type ElementType generic.Type

func FlattenElementTypeSlice

func FlattenElementTypeSlice(data interface{}) []ElementType

Directories

Path Synopsis
Package browser provides utilities for interacting with users' browsers.
Package browser provides utilities for interacting with users' browsers.
cmd

Jump to

Keyboard shortcuts

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