common

package
v0.0.0-...-c5d1e48 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2023 License: AGPL-3.0 Imports: 12 Imported by: 2

Documentation

Index

Constants

View Source
const (
	SUCCESS = "SUCCESS"
	FAIL    = "FAIL"
)
View Source
const Alphabet = "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM0123456789"
View Source
const Alphabet95 = "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM0123456789`~!@#$%^&*()_-+=[]\\;',./{}|:\"<>? "

Variables

View Source
var (
	NotSameTypeErr    = fmt.Errorf("cannot fill empty: the two value have different type")
	NeedPassInPointer = fmt.Errorf("the structure passed in should be a pointer")
)
View Source
var BadRequestErr = fmt.Errorf("bad request")
View Source
var Base62Encoder, _ = basex.NewEncoding(Alphabet)
View Source
var Base95Encoder, _ = basex.NewEncoding(Alphabet95)

Functions

func Abs

func Abs(a int) int

func BoolToInt

func BoolToInt(a bool) int

func BoolToString

func BoolToString(a bool) string

func Bytes2Sha1

func Bytes2Sha1(b []byte, salt []byte) []byte

func BytesCopy

func BytesCopy(b []byte) []byte

func Deduplicate

func Deduplicate(list []string) []string

func Expired

func Expired(expireAt time.Time) bool

func FillEmpty

func FillEmpty(toFill interface{}, defaultVal interface{}) error

FillEmpty fill the empty field of the struct with default value given

func HomeExpand

func HomeExpand(path string) (string, error)

func HostToSNI

func HostToSNI(host string, rootDomain string) (sni string, err error)

func IsCanceled

func IsCanceled(err error) bool

func Max

func Max(a, b int) int

func Min

func Min(a, b int) int

func Response

func Response(ctx *gin.Context, code Code, data interface{}) (status int, body gin.H)

func ResponseBadRequestError

func ResponseBadRequestError(ctx *gin.Context)

func ResponseError

func ResponseError(ctx *gin.Context, err error)

func ResponseSuccess

func ResponseSuccess(ctx *gin.Context, data interface{})

func SetValue

func SetValue(values *url.Values, key string, value string)

func SimplyGetParam

func SimplyGetParam(source string, key string) (value string)

func SliceHas

func SliceHas(slice []string, set []string) []string

func SliceSub

func SliceSub(slice []string, toSub []string) []string

func SliceToSet

func SliceToSet(slice []string) map[string]struct{}

func StringToUUID5

func StringToUUID5(str string) string

StringToUUID5 is from https://github.com/XTLS/Xray-core/issues/158

func StringsHas

func StringsHas(strs []string, str string) bool

func TrimLineContains

func TrimLineContains(parent, sub string) string

func UrlEncoded

func UrlEncoded(str string) string

UrlEncoded encodes a string like Javascript's encodeURIComponent()

Types

type Code

type Code string

type Resp

type Resp struct {
	Status int
	Body   gin.H
}

Jump to

Keyboard shortcuts

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