utils

package
v0.0.0-...-19598f2 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2025 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const BASE_CHAR = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
View Source
const NormalConsoleWidth = 80

Variables

This section is empty.

Functions

func AcceptMimeType

func AcceptMimeType(mimeType string, accept string) bool

func CheckCertWithDomain

func CheckCertWithDomain(cert *x509.Certificate, domain string) bool

func CheckCertWithTime

func CheckCertWithTime(cert *x509.Certificate, gracePeriod time.Duration) bool

func CheckIfSubPath

func CheckIfSubPath(parentPath, childPath string) bool

func CheckIfSubPathNotEqual

func CheckIfSubPathNotEqual(parentPath, childPath string) bool

func CleanFilePathAbs

func CleanFilePathAbs(pathstr string) (string, error)

func CountSpaceInStringPrefix

func CountSpaceInStringPrefix(str string) int

func EncodePrivateKeyToPEM

func EncodePrivateKeyToPEM(privateKey crypto.PrivateKey) ([]byte, error)

func ErrorExit

func ErrorExit(msg string, code ...int) int

func Exit

func Exit(code ...int) int

func ExitByError

func ExitByError(err error, code ...int) int

func ExitByErrorMsg

func ExitByErrorMsg(msg string, code ...int) int

func FilePathEqual

func FilePathEqual(path1, path2 string) bool

func FormatTextToWidth

func FormatTextToWidth(text string, width int) string

func FormatTextToWidthAndPrefix

func FormatTextToWidthAndPrefix(text string, prefixWidth int, overallWidth int) string

func GetArgs0

func GetArgs0() string

func GetArgs0Name

func GetArgs0Name() string

func GetCallingFunctionInfo

func GetCallingFunctionInfo(skip int) (string, string, string, int)

func GetGoVersion

func GetGoVersion() (int64, int64, int64, error)

func GetGoVersionMajor

func GetGoVersionMajor() (int64, error)

func GetGoVersionMajorMust

func GetGoVersionMajorMust() int64

func GetGoVersionMinor

func GetGoVersionMinor() (int64, error)

func GetGoVersionMinorMust

func GetGoVersionMinorMust() int64

func GetGoVersionPatch

func GetGoVersionPatch() (int64, error)

func GetGoVersionPatchMust

func GetGoVersionPatchMust() int64

func HasFieldByReflect

func HasFieldByReflect(typ reflect.Type, fieldName string) bool

func InvalidPhone

func InvalidPhone(phone string) bool

func IsDir

func IsDir(path string) bool

func IsExists

func IsExists(path string) bool

func IsFile

func IsFile(path string) bool

func IsGoodQueryKey

func IsGoodQueryKey(key string) bool

func IsValidDomain

func IsValidDomain(domain string) bool

func IsValidEmail

func IsValidEmail(email string) bool

func IsValidHTTPHeaderKey

func IsValidHTTPHeaderKey(key string) bool

func IsValidIPv4CIDR

func IsValidIPv4CIDR(cidr string) bool

func IsValidIPv6CIDR

func IsValidIPv6CIDR(cidr string) bool

IsValidIPv6CIDR checks if the given string is a valid IPv6 CIDR notation.

func IsValidURLPath

func IsValidURLPath(path string) bool

func ProcessURLPath

func ProcessURLPath(path string, defaultUrl ...string) string

设计理念: 通过把UPath添加'/',然后去除右端'/',实现url转换为'/abc'格式。 如此格式,恶意满足拼接的需求。 对于根路由,即'/',则转换为空白符好。

func Rand

func Rand() *rand.Rand

func RandStr

func RandStr(length int) string

func ReadCertificate

func ReadCertificate(data []byte) (*x509.Certificate, error)

func ReadPrivateKey

func ReadPrivateKey(data []byte) (crypto.PrivateKey, error)

func SayGoodByef

func SayGoodByef(format string, args ...interface{})

func SayHellof

func SayHellof(format string, args ...interface{})

func SplitHostPort

func SplitHostPort(hostPort string) (host, port string)

func StringToOnlyPrint

func StringToOnlyPrint(str string) string

func URLClone

func URLClone(old *url.URL) *url.URL

func ValidIPv4

func ValidIPv4(ipString string) bool

func ValidIPv6

func ValidIPv6(ipString string) bool

Types

type StringBool

type StringBool string

func (*StringBool) IsDisable

func (s *StringBool) IsDisable(defaultVal ...bool) (res bool)

func (*StringBool) IsEnable

func (s *StringBool) IsEnable(defaultVal ...bool) (res bool)

func (*StringBool) SetDefaultDisable

func (s *StringBool) SetDefaultDisable()

func (*StringBool) SetDefaultEnable

func (s *StringBool) SetDefaultEnable()

func (*StringBool) ToBool

func (s *StringBool) ToBool(defaultVal ...bool) bool

func (*StringBool) ToString

func (s *StringBool) ToString() string

func (*StringBool) ToStringDefaultDisable

func (s *StringBool) ToStringDefaultDisable() string

func (*StringBool) ToStringDefaultEnable

func (s *StringBool) ToStringDefaultEnable() string

Jump to

Keyboard shortcuts

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