util

package
v0.0.0-...-e2a5574 Latest Latest
Warning

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

Go to latest
Published: May 10, 2026 License: LGPL-2.1 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BodyDump

func BodyDump(ignore ...string) echo.MiddlewareFunc

func ConvertType

func ConvertType(sourceValue any, targetType reflect.Type) (any, error)

func CopyMap

func CopyMap[K comparable, V any](src map[K]V) map[K]V

CopyMap returns a shallow copy of src. Returns nil if src is nil.

func GenerateGJWToken

func GenerateGJWToken(password, deviceid, userid, issuer string,
	roles []string, expire_seconds int64) (string, error)

func GenerateGJWTokenWithTime

func GenerateGJWTokenWithTime(password string, deviceid string, userid string, issuer string, roles []string, expire_seconds int64, current time.Time) (string, error)

func GenerateRandomStr

func GenerateRandomStr(charset string, length int) (string, error)

func GenerateServerToken

func GenerateServerToken(password, systemid, userid, issuer string,
	roles []string, expire_seconds int64) (string, error)

func GenerateServerTokenWithTime

func GenerateServerTokenWithTime(password string, systemid string, userid string, issuer string, roles []string, expire_seconds int64, current time.Time) (string, error)

func GetContentType

func GetContentType(ext string) string

func ImplementsInterface

func ImplementsInterface(target reflect.Type, theInterface reflect.Type) bool

func IsArrayType

func IsArrayType(target reflect.Type) bool

func IsConvertible

func IsConvertible(sourceValue any, targetType reflect.Type) bool

func IsEmptyStr

func IsEmptyStr(target *string) bool

func IsErrorObj

func IsErrorObj(target interface{}) bool

func IsErrorType

func IsErrorType(target reflect.Type) bool

func IsFuncType

func IsFuncType(target reflect.Type) bool

func IsInterfaceType

func IsInterfaceType(target reflect.Type) bool

func IsPointerType

func IsPointerType(target reflect.Type) bool

func IsStructType

func IsStructType(target reflect.Type) bool

func ToPtr

func ToPtr[T interface{}](source T) *T

func Unused

func Unused(_ ...interface{})

Unused is for avoiding unused variable error, in case you want to run debugging and inspect the variable value. Example:

svc := NewService();
utility.Unused(svc); // Now put breakpoint and run debugger here.

func ValueOrZeroOf

func ValueOrZeroOf[T interface{}](ptr *T) T

Types

type GJWCustomClaims

type GJWCustomClaims struct {
	UserId string   `json:"userid,omitempty"`
	DId    string   `json:"did,omitempty"`
	Roles  []string `json:"roles"`
	jwt.RegisteredClaims
}

type GJWTokenPayload

type GJWTokenPayload struct {
	UserId string   `json:"userid,omitempty"`
	DId    string   `json:"did,omitempty"`
	Roles  []string `json:"roles"`
}

func ParseGJWToken

func ParseGJWToken(tokenString string, password string) (*GJWTokenPayload, error)

type ServerCustomClaims

type ServerCustomClaims struct {
	SystemId string   `json:"systemid"`
	UserId   string   `json:"userid"`
	Roles    []string `json:"roles"`
	jwt.RegisteredClaims
}

type ServerTokenPayload

type ServerTokenPayload struct {
	UserId   string   `json:"userid"`
	SystemId string   `json:"systemid"`
	Roles    []string `json:"roles"`
}

Jump to

Keyboard shortcuts

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