vutils

package
v2.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Config = LoadConfig()
View Source
var HTTPBaseCookie http.Cookie

HTTPBaseCookie defines the base cookie setup for vcago

View Source
var NatsHost string

NatsHost is the ip of the nats service.

View Source
var NatsPort string

NatsPort is the port ot the nats service.

Functions

func RandomBase64

func RandomBase64(n int) (string, error)

RandomBase64 generate random Base64 string

func RandomBytes

func RandomBytes(n int) ([]byte, error)

RandomBytes return random bytes

Types

type LinkToken

type LinkToken struct {
	ID        string `bson:"_id" json:"id"`
	Code      string `bson:"code" json:"code"`
	ModelID   string `bson:"model_id" json:"model_id"`
	Scope     string `bson:"scope" json:"scope"`
	ExpiresAt int64  `bson:"expires_at" json:"expires_at"`
	Created   int64  `bson:"created" json:"created"`
}

func NewLinkToken

func NewLinkToken(scope string, expired time.Duration, modelID string) (r *LinkToken, err error)

func (*LinkToken) NewCode

func (r *LinkToken) NewCode(expired time.Duration) (err error)

type LoadEnv

type LoadEnv []bool

LoadEnv used for loading environment variables.

func LoadConfig

func LoadConfig() *LoadEnv

func (LoadEnv) GetEnvBool

func (l LoadEnv) GetEnvBool(key string, lvl string, dVal bool) bool

GetEnvBool load a key from environment variables as bool.

func (LoadEnv) GetEnvInt

func (l LoadEnv) GetEnvInt(key string, lvl string, dVal int) int

GetEnvInt loads a key from enviroment variables as int. The lvl param defines the log level. For warnings set "w" and for error set "e". If the variable is not used or can be ignored use n for do nothing. The default value can be set by the dVal param.

func (LoadEnv) GetEnvString

func (l LoadEnv) GetEnvString(key string, lvl string, dVal string) string

GetEnvString loads a key from enviroment variables as string. The lvl param defines the log level. For warnings set "w" and for error set "e". If the variable is not used or can be ignored use n for do nothing. The default value can be set by the dVal param.

func (LoadEnv) GetEnvStringList

func (l LoadEnv) GetEnvStringList(key string, lvl string, dVal []string) []string

GetEnvStringList as

func (LoadEnv) Validate

func (l LoadEnv) Validate()

Validate check if LoadEnv is valid and log.Fatal if on entry is false.

Jump to

Keyboard shortcuts

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