util

package
v0.0.0-...-bae350f Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEmptyKey       = fmt.Errorf("env: empty key")
	ErrValueNotNumber = fmt.Errorf("env: the value is not a number")
)

Functions

func EncodeJWT

func EncodeJWT(id int64, issuer, secret string, expiry time.Duration) (string, error)

func GetEnv

func GetEnv(key string) (string, error)

func GetIntEnv

func GetIntEnv(key string) (int, error)

func MustGetEnv

func MustGetEnv(key string) string

func MustGetIntEnv

func MustGetIntEnv(key string) int

func MustSetEnv

func MustSetEnv(key, val string)

func MustSetIntEnv

func MustSetIntEnv(key string, val int)

func ReadEnvFile

func ReadEnvFile(path string) error

func SetEnv

func SetEnv(key, val string) error

func SetIntEnv

func SetIntEnv(key string, val int) error

func StrSliceContains

func StrSliceContains(arr []string, val string) bool

func StrSliceIntersects

func StrSliceIntersects(a, b []string) []string

func ValidateStruct

func ValidateStruct(val interface{}) []error

func ValidtateValue

func ValidtateValue(val interface{}, tag string) []error

Types

type Envs

type Envs struct {
}

func NewEnvs

func NewEnvs() *Envs

func (*Envs) Get

func (e *Envs) Get(key string) (string, error)

func (*Envs) GetInt

func (e *Envs) GetInt(key string) (int, error)

func (*Envs) MustGet

func (e *Envs) MustGet(key string) string

func (*Envs) MustGetInt

func (e *Envs) MustGetInt(key string) int

func (*Envs) MustSet

func (e *Envs) MustSet(key, val string)

func (*Envs) MustSetInt

func (e *Envs) MustSetInt(key string, val int)

func (*Envs) ReadFile

func (e *Envs) ReadFile(path string) error

func (*Envs) Set

func (e *Envs) Set(key, val string) error

func (*Envs) SetInt

func (e *Envs) SetInt(key string, val int) error

type JWTClaims

type JWTClaims struct {
	jwt.StandardClaims

	UserId int64 `json:"userId"`
}

func DecodeJWT

func DecodeJWT(token, secret string) (*JWTClaims, error)

type Validator

type Validator struct {
	// contains filtered or unexported fields
}

func NewValidator

func NewValidator() *Validator

func (*Validator) Struct

func (v *Validator) Struct(val interface{}) []error

func (*Validator) Value

func (v *Validator) Value(val interface{}, tag string) []error

Jump to

Keyboard shortcuts

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