define

package
v1.16.0 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package define implements functions separate of project.

Index

Constants

This section is empty.

Variables

View Source
var Atoi = func(x string) int { xInt, _ := strconv.Atoi(x); return xInt }

Atoi convet string to int.

View Source
var Itoa = strconv.Itoa

Itoa convet int to string.

View Source
var Itob = func(v int) []byte {
	b := make([]byte, 8)
	binary.BigEndian.PutUint64(b, uint64(v))
	return b
}

Itob convet int to []byte.

View Source
var ParseFloat = func(x string) float64 { xFloat, _ := strconv.ParseFloat(x, 64); return xFloat }
View Source
var ParseUint = func(x string) uint { xUint, _ := strconv.ParseUint(x, 10, 0); return uint(xUint) }

Functions

func Abs

func Abs[T constraints.Integer](a T) T

func BasicAuth added in v0.10.0

func BasicAuth(username, password string) string

func ChangeFieldOfName

func ChangeFieldOfName(imodel interface{}, field_name string, value interface{}) error

func Check

func Check(imodel interface{}, field_name string) (*reflect.Value, error)

func Compare added in v0.13.0

func Compare(a, b any) int

Compare returns

-2 if a == nil || b == nil
-1 if a < b
 0 if a == b
+1 if a > b

func Contains

func Contains[T comparable](s []T, e T) bool

Contains returns

func CopyMap

func CopyMap[T1, T2 comparable](Map map[T1]T2) map[T1]T2

func CopyMapAny

func CopyMapAny[T1, T2 comparable](Map map[T1]T2) map[string]any

func GetDecodeFunc

func GetDecodeFunc(format string) func(io.Reader) (image.Image, error)

func GetEncodeFunc

func GetEncodeFunc(format string) func(io.Writer, image.Image) error

func GetImagesFromRequestBody

func GetImagesFromRequestBody(body []byte, key ...string) ([]image.Image, []string)

func GetJSONResponse added in v0.10.0

func GetJSONResponse(method, curl string, headers Headers, data Data) (int, any, error)

func GetResponse added in v0.10.0

func GetResponse(method, curl string, headers Headers, data Data) (int, []byte, error)

func GetTagField added in v0.11.0

func GetTagField(model any, fieldName string, tagName ...string) string

func GetToday

func GetToday() string

GetToday returns string today date.

func GoToStruct

func GoToStruct(value reflect.Value) (*reflect.Value, error)

func Hash

func Hash(data []byte) string

Hash returns hash data

func ImagesToBytes

func ImagesToBytes(images []image.Image, formats []string) [][]byte

func IndexOf

func IndexOf[T comparable](lst []T, x T) int

func Insert

func Insert[T constraints.Ordered](a []T, index int, value T) []T

func Max

func Max[T constraints.Ordered](args ...T) T

Max return maximal value in args.

func Min

func Min[T constraints.Ordered](args ...T) T

Min return minimal value in args.

func Pop

func Pop[T comparable](lst []T, index int) ([]T, T)

func Pow

func Pow[T constraints.Integer](a T, b T) float64

func Sum added in v0.13.0

func Sum[T constraints.Ordered](args ...T) T

Sum return sum value in args.

Types

type Data added in v0.10.0

type Data map[string]any

type Headers added in v0.10.0

type Headers map[string]string

type Set

type Set[T constraints.Ordered] struct {
	// contains filtered or unexported fields
}

func (*Set[T]) Add

func (this *Set[T]) Add(x T)

func (*Set[T]) Adds

func (this *Set[T]) Adds(lst ...T)

func (*Set[T]) Count

func (this *Set[T]) Count() int

func (*Set[T]) Get

func (this *Set[T]) Get(index int) T

func (*Set[T]) GetItems

func (this *Set[T]) GetItems() []T

Jump to

Keyboard shortcuts

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