util

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Ki = 1 << 10
	Mi = 1 << 20
	Gi = 1 << 30
	Ti = 1 << 40
	Pi = 1 << 50
	Ei = 1 << 60
)

<binarySI> ::= Ki | Mi | Gi | Ti | Pi | Ei refer from: resource/quantity.go

View Source
const (
	JSONMarshalPrefix = ""
	JSONMarshalIndent = "  "
)

Variables

View Source
var BackgroundContext = context.Background()
View Source
var DefaultHTTPClient = http.DefaultClient
View Source
var (
	DefaultPage = NewPageConfig(1, 10)
)

DefaultPage immutable default page config

View Source
var TODOContext = context.TODO()

Functions

func Bytes2StringNoCopy

func Bytes2StringNoCopy(bs []byte) string

func CST2Timestamp added in v1.1.0

func CST2Timestamp(cst string) string

func ConRun added in v1.1.0

func ConRun(fns ...Fn)

func GetTypeByteSize added in v1.1.0

func GetTypeByteSize(varOf any) uintptr

func GetValueByteSize added in v1.1.0

func GetValueByteSize(varOf any) int

func HandleCloseError added in v1.1.0

func HandleCloseError(msg string, closer io.Closer)

HandleCloseError handle io closer error

func I64toa added in v1.1.0

func I64toa(i64 int64) string

func IsURLWithHTTP added in v1.1.0

func IsURLWithHTTP(url string) bool

func IsURLWithHTTPS added in v1.1.0

func IsURLWithHTTPS(url string) bool

func IsURLWithScheme added in v1.1.0

func IsURLWithScheme(url string) bool

func MarshalJSONPretty added in v1.1.0

func MarshalJSONPretty(v any) (string, error)

func New

func New[T any](val T) *T

func NewBool

func NewBool(bVar bool) *bool

func NewFloat32

func NewFloat32(f32 float32) *float32

func NewFloat64

func NewFloat64(f64 float64) *float64

func NewInt32

func NewInt32(i32 int32) *int32

func NewInt64

func NewInt64(i64 int64) *int64

func NewString

func NewString(str string) *string

func OSCreateAbsoluteDir added in v1.1.0

func OSCreateAbsoluteDir(dir string) error

func OSCreateAbsolutePath added in v1.1.0

func OSCreateAbsolutePath(filePath string) error

func OSFilePathExists added in v1.1.0

func OSFilePathExists(filePath string) bool

func OSOpenFileWithCreate added in v1.1.0

func OSOpenFileWithCreate(filePath string) (*os.File, error)

func OSRemoveFile added in v1.1.0

func OSRemoveFile(filePath string) error

func ReadYaml added in v1.1.0

func ReadYaml(a any, filePath string) error

ReadYaml Deprecated gopkg.in/aml.v3 can not reflect twice

func SeqRun added in v1.1.0

func SeqRun(fns ...Fn)

func SilentHandleError

func SilentHandleError(handle string, err error)

SilentHandleError only used in dev env or test env, _test file not to use in production env

func SilentPanicError added in v1.1.0

func SilentPanicError(err error)

SilentPanicError only used in dev env or test env, _test file not to use in production env

func String2BytesNoCopy

func String2BytesNoCopy(s string) []byte

func StringConcat

func StringConcat(s ...string) string

func StringJoin added in v1.1.0

func StringJoin(sep string, s ...string) string

func StringReplaceAlls added in v1.1.0

func StringReplaceAlls(s, to string, from ...string) string

func Timestamp2CST added in v1.1.0

func Timestamp2CST(timestamp string) string

func URLWithHTTP

func URLWithHTTP(url string) string

func URLWithoutHTTP added in v1.1.0

func URLWithoutHTTP(url string) string

Types

type Fn added in v1.1.0

type Fn func()
var (
	NothingFn Fn = func() {}
	DoNothing Fn = func() {}
)

type Func

type Func func() error

type JSONEncoder added in v1.1.0

type JSONEncoder interface {
	String() string
	Bytes() []byte
	Size() int64
}

type Page

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

func NewPageConfig

func NewPageConfig(pageNum, pageSize int64) *Page

func (*Page) Page

func (p *Page) Page() *int64

func (*Page) PageIntValue added in v1.1.0

func (p *Page) PageIntValue() int

func (*Page) PageValue added in v1.1.0

func (p *Page) PageValue() int64

func (*Page) Pair

func (p *Page) Pair() (*int64, *int64)

func (*Page) PairValue added in v1.1.0

func (p *Page) PairValue() (int64, int64)

func (*Page) Size

func (p *Page) Size() *int64

func (*Page) SizeIntValue added in v1.1.0

func (p *Page) SizeIntValue() int

func (*Page) SizeValue added in v1.1.0

func (p *Page) SizeValue() int64

func (*Page) WithOffsetNum

func (p *Page) WithOffsetNum(offsetNum int64) *Page

func (*Page) WithPageNum

func (p *Page) WithPageNum(pageNum int64) *Page

func (*Page) WithPageSize

func (p *Page) WithPageSize(pageSize int64) *Page

type StdJSONEncoder added in v1.1.0

type StdJSONEncoder interface {
	String() (string, error)
	Bytes() ([]byte, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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