gopromax

package module
v0.0.0-...-54c5172 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2024 License: GPL-3.0 Imports: 19 Imported by: 0

README

go-pro-max

enhancement tool for go

INSTALL

go get github.com/BruceCatYu/go-pro-max

LICENSE

This project licensed under the GNU General Public License v3.0

SPONSOR

If you like my project, Please sponsor me at Buy me a coffee 🐭🐭
Buy me a coffee

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClapNumber

func ClapNumber[T NumericType](n, left, right T) T

func ClearFile

func ClearFile(path string) error

ClearFile clear text by file path

func EqualFold

func EqualFold(s, t string) bool

EqualFold is strings.EqualFold, ASCII only. It reports whether s and t are equal, ASCII-case-insensitively.

func FileExists

func FileExists(path string) (has bool, err error)

FileExists check file exists

func Find

func Find[T any](s []T, f func(T) bool) *T

func FindIndexOf

func FindIndexOf[T any](s []T, f func(T) bool) int

func GBKToUTF8

func GBKToUTF8(b []byte) []byte

GBKToUTF8 trans GBK string to UTF8 string

func Gzip

func Gzip(b []byte) []byte

func IndexOf

func IndexOf[T comparable](s []T, e T) int

func LastIndexOf

func LastIndexOf[T comparable](s []T, e T) int

func Lower

func Lower(b byte) byte

Lower returns the ASCII lowercase version of b.

func MapToStruct

func MapToStruct(m, s any) error

MapToStruct marshal map and then unmarshal to struct s must be a pointer of variable

func MarshalBeautyJSON

func MarshalBeautyJSON(v any) ([]byte, error)

MarshalBeautyJSON return beauty json

func MaxNumber

func MaxNumber[T NumericType](a, b T) T

func MinNumber

func MinNumber[T NumericType](a, b T) T

func NumericAdd

func NumericAdd[T NumericType](a, b T) T

func NumericMinus

func NumericMinus[T NumericType](a, b T) T

func ParseLocalTime

func ParseLocalTime(s string) (t time.Time)

ParseLocalTime Parse string to local time

func RandomNumeric

func RandomNumeric[T NumericType](left, right T) (res T)

func StringCut

func StringCut(s, sep string) (before, after string, found bool)

Cut slices s around the first instance of sep, returning the text before and after sep. The found result reports whether sep appears in s. If sep does not appear in s, cut returns s, "", false.

func StripSpaces

func StripSpaces(str string) string

StripSpaces remove all space char in string

func ToMd5

func ToMd5(str string) string

ToMd5

func UnGzip

func UnGzip(b []byte) ([]byte, error)

func UnGzipToJson

func UnGzipToJson[T any](v *T, b []byte) (*T, error)

Types

type FileTailLine

type FileTailLine struct {
	Str   string // content
	Count int64  // line count
	Err   error  // error
}

func ReadTailN

func ReadTailN(f *os.File, n int64) *FileTailLine

ReadTailN read file tail with n line

type Node

type Node[T cmp.Ordered] struct {
	// contains filtered or unexported fields
}

func (*Node[T]) Add

func (n *Node[T]) Add(v T) *Node[T]

func (*Node[T]) Contains

func (n *Node[T]) Contains(v T) bool

type NumericType

type NumericType interface {
	~int | ~int8 | ~int16 | ~int32 | ~int64 |
		~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 |
		~float32 | ~float64
}

type Response

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

func NewResponse

func NewResponse(w *http.ResponseWriter, r *http.Request) Response

func (*Response) BodyBytes

func (res *Response) BodyBytes() ([]byte, error)

func (*Response) BodyJSON

func (res *Response) BodyJSON(v any) error

func (*Response) BodyString

func (res *Response) BodyString() (string, error)

func (*Response) PathVar

func (res *Response) PathVar(v string) []string

func (*Response) RespErr

func (res *Response) RespErr(data any)

func (*Response) RespJSON

func (res *Response) RespJSON(httpCode int, body any)

func (*Response) RespNoAuth

func (res *Response) RespNoAuth(data any)

func (*Response) RespOk

func (res *Response) RespOk(data any)

type Ternary

type Ternary struct {
	Expr1, Expr2, Expr3 any
}

func (*Ternary) Calculate

func (t *Ternary) Calculate() any

type Tree

type Tree[T cmp.Ordered] struct {
	// contains filtered or unexported fields
}

func NewTree

func NewTree[T cmp.Ordered](v T) *Tree[T]

func (*Tree[T]) Add

func (t *Tree[T]) Add(v T)

func (*Tree[T]) Contains

func (t *Tree[T]) Contains(v T) bool

type WaitGroup

type WaitGroup struct {
	sync.WaitGroup
}

func (*WaitGroup) Wrap

func (w *WaitGroup) Wrap(f func())

Jump to

Keyboard shortcuts

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