helper

package
v0.0.0-...-9c4fc95 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const Iso8601 = "2006-01-02"
View Source
const Rfc2822 = "Mon Jan 02 15:04:05 -0700 2006"
View Source
const Yyyymmddhhmmss = "2006/01/02 15:04:05"

Variables

View Source
var (
	RootPath = filepath.Join(filepath.Dir(b), "../..")
)

Functions

func BadRequest

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

func CalcTimeRange

func CalcTimeRange(fromDate string, toDate string) int64

func CheckDirectoryExists

func CheckDirectoryExists(dir string) bool

func CheckHash

func CheckHash(hash string, secret string) error

func ConvertInterfaceToIntMap

func ConvertInterfaceToIntMap(i []interface{}) []int

func ConvertStringToDateTimeString

func ConvertStringToDateTimeString(s string) (string, error)

func ConvertToBool

func ConvertToBool(any interface{}) bool

func ConvertToFloat64

func ConvertToFloat64(any interface{}) float64

func ConvertToInt

func ConvertToInt(any interface{}) int

func ConvertToString

func ConvertToString(any interface{}) string

func CreateHash

func CreateHash(secret string) string

func CreateMD5

func CreateMD5(secret interface{}) string

func CreateSHA1

func CreateSHA1(secret interface{}) string

func CreateUuid

func CreateUuid() string

func CurrentDateTimeIsGreaterThanSpecifiedDateTime

func CurrentDateTimeIsGreaterThanSpecifiedDateTime(t *time.Time) bool

func DebugPrintf

func DebugPrintf(any interface{})

func Fail

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

func GetBytes

func GetBytes(key interface{}) ([]byte, error)

func GetCurrentGoFilePath

func GetCurrentGoFilePath() string

func GetDateTimeByTraditionalChinese

func GetDateTimeByTraditionalChinese[T string | time.Time](t T) (time.Time, error)

func GetFileContentType

func GetFileContentType(extension string) string

func GetFileExtensionByContentType

func GetFileExtensionByContentType(contentType string) string

func GetFunctionName

func GetFunctionName() string

func GetGinRequest

func GetGinRequest(c *gin.Context)

func GetJSON

func GetJSON(value interface{}) string

func GetNextWeekDayDateTime

func GetNextWeekDayDateTime(wdt time.Time) time.Time

func GetNowDateTimeByFormat

func GetNowDateTimeByFormat(format string) string

func GetOS

func GetOS() string

func GetPathSeparator

func GetPathSeparator() string

func GetPostJSON

func GetPostJSON(ctx *gin.Context)

func GetSpecifyNextWeekDayDateTime

func GetSpecifyNextWeekDayDateTime(wdt time.Time) time.Time

func GetSpecifyNextWeekDayDateTimeByString

func GetSpecifyNextWeekDayDateTimeByString(wdts string) time.Time

func GetStructName

func GetStructName(s interface{}) string

func GetTimeByTimeString

func GetTimeByTimeString(ts string) (*time.Time, error)

func GetType

func GetType(value interface{})

func GetWeekDayEnglishByTraditionalChinese

func GetWeekDayEnglishByTraditionalChinese(traditionalChinese string) string

func GetWeekDayShortTraditionalChineseByEnglish

func GetWeekDayShortTraditionalChineseByEnglish(english string) string

func GetWeekDayTraditionalChineseByEnglish

func GetWeekDayTraditionalChineseByEnglish(english string) string

func GetWeekDays

func GetWeekDays() []string

func IsDateTime

func IsDateTime(s string) bool

func IsRunnigTest

func IsRunnigTest() bool

func IsShortDateOrTraditionalChineseShortDate

func IsShortDateOrTraditionalChineseShortDate(tc string) bool

func IsValidUUID

func IsValidUUID(u string) bool

func Pluck

func Pluck(any interface{}, key string) interface{}

func Response

func Response(ctx *gin.Context, value interface{}, err error)

func ShortDateIsEveryDay

func ShortDateIsEveryDay(tc string) bool

func SliceToSet

func SliceToSet(any interface{}) interface{}

func Success

func Success(ctx *gin.Context, value interface{}, message interface{})

func TruncateString

func TruncateString(s string, maxLength int) string

func Unauthorized

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

func UploadSuccess

func UploadSuccess(ctx *gin.Context, value interface{}, message interface{})

func ValidJSONWebToken

func ValidJSONWebToken(requestToken string) bool

func ValidateURL

func ValidateURL(str string) bool

Types

type Result

type Result struct {
	Value interface{}
	Error interface{}
}

type Token

type Token struct {
	Token string
	Exp   int64
}

func CreateJWT

func CreateJWT(sercrt []byte) (token Token)

Jump to

Keyboard shortcuts

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