utils

package
v0.0.0-...-75939a1 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2022 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// StatusClientClosed is non-standard http status code,
	// which defined by nginx.
	// https://httpstatus.in/499/
	StatusClientClosed = 499
)

Variables

This section is empty.

Functions

func CamelString

func CamelString(s string) string

下划线字符转小写驼峰

func CheckEmail

func CheckEmail(email string) bool

检查是否邮箱

func CheckMobile

func CheckMobile(mobile string) bool

简称是否手机号

func ContentSubtype

func ContentSubtype(contentType string) string

ContentSubtype returns the content-subtype for the given content-type. The given content-type must be a valid content-type that starts with but no content-subtype will be returned. according rfc7231. contentType is assumed to be lowercase already.

func ContentType

func ContentType(subtype string) string

ContentType returns the content-type with base prefix.

func DecimalRoundAdd

func DecimalRoundAdd(a, b float64) float64

func GRPCCodeFromStatus

func GRPCCodeFromStatus(code int) codes.Code

GRPCCodeFromStatus converts a HTTP error code into the corresponding gRPC response status. See: https://github.com/googleapis/googleapis/blob/master/google/rpc/code.proto

func GenIdStringAsDateFormat

func GenIdStringAsDateFormat() string

func GetClientIp

func GetClientIp(ctx context.Context) string

func GetEndMonth

func GetEndMonth(end time.Time) uint32

func GetFirstDateOfWeek

func GetFirstDateOfWeek() time.Time

获取本周周一时间

func GetFirstOfMonth

func GetFirstOfMonth(now time.Time) time.Time

获取月初时间

func GetFirstOfMonthForStr

func GetFirstOfMonthForStr(month string) time.Time

func GetFirstOfQuarter

func GetFirstOfQuarter(now time.Time) time.Time

获取月初时间

func GetFirstOfWeek

func GetFirstOfWeek(now time.Time) time.Time

获取某个周一时间

func GetLastOfMonth

func GetLastOfMonth(now time.Time) time.Time

获取月末时间

func GetLastOfMonthForStr

func GetLastOfMonthForStr(month string) time.Time

func GetLastWeekFirstDate

func GetLastWeekFirstDate() time.Time

获取上周的周一日期

func GetMonthDiff

func GetMonthDiff(start, end time.Time) uint32

func GetOfficeLimit

func GetOfficeLimit(page, pageSize *uint32) (int, int)

func JsonBytes

func JsonBytes(v interface{}) []byte

func JsonString

func JsonString(v interface{}) string

func MD5String

func MD5String(str string) string

func NewCaptchaDriver

func NewCaptchaDriver() *captcha.DriverString

func PBTimeString

func PBTimeString(timestamp *timestamppb.Timestamp) string

func ParseLocalTime

func ParseLocalTime(layout string, value string) (time.Time, error)

func RandomIntStr

func RandomIntStr(n int) string

func RandomString

func RandomString(n int) string

func StatusFromGRPCCode

func StatusFromGRPCCode(code codes.Code) int

StatusFromGRPCCode converts a gRPC error code into the corresponding HTTP response status. See: https://github.com/googleapis/googleapis/blob/master/google/rpc/code.proto

func SubMonth

func SubMonth(t1, t2 time.Time) (month int)

计算日期相差多少月

func Timestamppb

func Timestamppb(now *time.Time) *timestamppb.Timestamp

func UnitJoin

func UnitJoin(elems []uint32, sep string) string

func UnitSplit

func UnitSplit(s, sep string) []uint32

func UnsafeStringToInt64

func UnsafeStringToInt64(str string) int64

func UnsafeStringToUInt32

func UnsafeStringToUInt32(str string) uint32

func VerifyAccount

func VerifyAccount(account string) bool

func VerifyIsBankNo

func VerifyIsBankNo(no string) bool

func VerifyIsCompany

func VerifyIsCompany(name string) bool

func VerifyIsIpaddress

func VerifyIsIpaddress(ip string) bool

func VerifyIsMail

func VerifyIsMail(mail string) bool

func VerifyIsPasswd

func VerifyIsPasswd(passwd string) bool

func VerifyIsPhoneNumber

func VerifyIsPhoneNumber(phone string) bool

func VerifyIsTaxID

func VerifyIsTaxID(taxID string) bool

func VerifyIsZipCode

func VerifyIsZipCode(code string) bool

Types

type Query

type Query interface {
	Offset(offset int)
	Limit(limit int)
}

type StringTypeMap

type StringTypeMap []string

func (StringTypeMap) CheckKey

func (s StringTypeMap) CheckKey(v string) bool

Jump to

Keyboard shortcuts

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