utils

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2018 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const ALPH = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"

ALPH are alphabet letters in lower and upper case

View Source
const NUM = "0123456789"

NUM are numbers [0:10)

View Source
const SPECIAL = "!#$%&()*+,-./:;><?^_"

SPECIAL are special characters

Variables

This section is empty.

Functions

func BcryptHash added in v0.2.0

func BcryptHash(text string, costs int) string

BcryptHash returns a string representation of a hashed text with given cost

func DecodeBase64

func DecodeBase64(enc *base64.Encoding, text string) string

DecodeBase64 decodes a base64 string to it's plain text representation

func DecodeURI added in v1.0.1

func DecodeURI(decodedURI string) (string, error)

DecodeURI does the inverse transformation of EncodeUri. Currently it's just a delegate for uri.QueryUnescape.

func EncodeBase64

func EncodeBase64(enc *base64.Encoding, text string) string

EncodeBase64 encodes a plain string to it's base64 representation

func EncodeURI added in v1.0.1

func EncodeURI(uri string) string

EncodeURI encodes a string so it can safely placed inside an URL.

func Hash

func Hash(hash hash.Hash, text string) string

Hash returns a string representation of a given hash function

func Open added in v1.0.1

func Open(url string)

Open opens the default system browser and points to the given url.

func ParseTimestamp

func ParseTimestamp(date string) (time.Time, error)

ParseTimestamp tries to parses a string into a time.Time format. The following cascade is used: 1. It tries to parse the string as current time millis. 2. It tries to parse the string as current time nanos. 3. It tries to parse the string as RFC 3339 time.

func Random added in v0.0.2

func Random(n int, a Source) string

Random generates a random string with a length of n. Each letter of the random string has it's source in the given source a

func RandomNumber added in v0.0.2

func RandomNumber(n int) string

RandomNumber generates a random number with a length of n. Each letter of the random string has it's source in the Numeric source, but the first number of the string is in a range of [1,10)

Types

type AlphaNumeric added in v0.0.2

type AlphaNumeric struct{}

AlphaNumeric is a source of letters and numbers: abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789

type Alphabet added in v0.0.2

type Alphabet struct{}

Alphabet is a source of letters: abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ

type Complex added in v0.0.2

type Complex struct{}

Complex is the same as the AlphaNumeric source but adds also special characters

type Numeric added in v0.0.2

type Numeric struct{}

Numeric is a default source of numbers in a range of [0,10).

type Semaphore added in v0.0.2

type Semaphore chan struct{}

Semaphore is a semaphore for acquiring and releasing resources.

func (Semaphore) Acquire added in v0.0.2

func (s Semaphore) Acquire(n int)

Acquire n resources.

func (Semaphore) Release added in v0.0.2

func (s Semaphore) Release(n int)

Release n resources.

type Source added in v0.0.2

type Source interface {
	// contains filtered or unexported methods
}

Source defines a string of letters used as source for a random string

Jump to

Keyboard shortcuts

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