util

package
v0.0.0-...-a19afdd Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2026 License: LGPL-2.1 Imports: 12 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 EndOfDay

func EndOfDay(t time.Time) time.Time

func EndOfHour

func EndOfHour(t time.Time) time.Time

func EndOfMonth

func EndOfMonth(t time.Time) time.Time

func EndOfYear

func EndOfYear(t time.Time) time.Time

func FloorDay

func FloorDay(t time.Time) time.Time

func FloorHour

func FloorHour(t time.Time) time.Time

func FloorMonth

func FloorMonth(t time.Time) time.Time

func FloorYear

func FloorYear(t time.Time) time.Time

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 Optional

type Optional[T any] struct {
	// contains filtered or unexported fields
}

Optional distinguishes three JSON states for the same field:

  • Absent : key is missing from the JSON body. IsSet() == false.
  • Null : key is present with value `null`. IsSet() == true, Get() == nil.
  • Value : key is present with a real value. IsSet() == true, Get() != nil.

Use it in DTOs when partial-update semantics are required so the mapper can skip the field entirely on absence, clear it on null, or set it on value.

func NewOptional

func NewOptional[T any](v T) Optional[T]

func NewOptionalNull

func NewOptionalNull[T any]() Optional[T]

func (Optional[T]) Get

func (this Optional[T]) Get() *T

func (Optional[T]) IsNull

func (this Optional[T]) IsNull() bool

func (Optional[T]) IsSet

func (this Optional[T]) IsSet() bool

func (Optional[T]) MarshalJSON

func (this Optional[T]) MarshalJSON() ([]byte, error)

func (*Optional[T]) UnmarshalJSON

func (this *Optional[T]) UnmarshalJSON(data []byte) 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