utility

package
v0.0.0-...-765b6f4 Latest Latest
Warning

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

Go to latest
Published: May 10, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const TimeMillis = "15:04:05.000"

Variables

This section is empty.

Functions

func AnyBlank

func AnyBlank(args ...string) bool

AnyBlank has any empty value return true otherwise return false

func Apply

func Apply[T any](o *T, opts ...Option[T])

func B64Decode

func B64Decode(src []byte) []byte

func Blanks

func Blanks(args ...string) bool

Blanks all value empty return true otherwise return false

func Bytes

func Bytes(data string) []byte

Bytes convert string to []byte

func DObj

func DObj[T any](source, d T) T

DObj returns source if not nil else return default value

func DString

func DString(source, d string) string

DString returns d if source blank else return source

func ErrorArgument

func ErrorArgument(err error) error

func ErrorArgumentf

func ErrorArgumentf(format string, v ...any) error

func ExternalIp

func ExternalIp() (net.IP, bool)

func FileExists

func FileExists(path string) bool

func First

func First[S ~[]E, E any](d E, list S) E

func IntranetIp

func IntranetIp() (net.IP, bool)

func IsBlank

func IsBlank(b string) bool

func IsEmail

func IsEmail(email string) bool

func Language

func Language(ctx context.Context) language.Tag

func MDExtract

func MDExtract(ctx context.Context, key string) (string, bool)

func Nils

func Nils(objs ...any) bool

Nils all values is nil return true otherwise return false

func NonBlank

func NonBlank(v string) bool

func NonBlanks

func NonBlanks(args ...string) bool

NonBlanks has any empty string returns false otherwise return true

func RandomTCPListener

func RandomTCPListener() (net.Listener, error)

func SQLString

func SQLString(s string) sql.NullString

SQLString returns a valid sql.NullString

func SetDefaultLanguage

func SetDefaultLanguage(lang language.Tag)

func String

func String(data []byte) string

String convert []byte to string

Types

type Option

type Option[T any] interface {
	// contains filtered or unexported methods
}

type OptionFunc

type OptionFunc[T any] func(*T)

type ResponseEntity

type ResponseEntity interface {
	Code() int
	Error() string
	Marshal() ([]byte, error)
	MarshalIdent() ([]byte, error)
}

func NewErrResponse

func NewErrResponse(code int, msg string) ResponseEntity

func NewResponse

func NewResponse(payload any) ResponseEntity

type SafeRunner

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

func NewSafeRunner

func NewSafeRunner() *SafeRunner

func (*SafeRunner) Err

func (r *SafeRunner) Err() error

func (*SafeRunner) Run

func (r *SafeRunner) Run(fn func() error)

Jump to

Keyboard shortcuts

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