Documentation
¶
Index ¶
- Variables
- func CalculateAge(birthdate time.Time) int
- func Decrypt(key []byte, ciphertext string) (string, error)
- func Encrypt(key []byte, plaintext string) (string, error)
- func GenerateRandomAlphanumeric(length int) string
- func GenerateRandomIndexes(max, count int) []int
- func Get(apiUrl string, params url.Values, res any) error
- func GetAgeFromStringDate(dateStr string) (int, error)
- func GetRandomUniqueStrings(arr []string, count int) ([]string, error)
- func GetRemainingSecondsToday() time.Duration
- func ParseInt(s string) int64
- func Post(apiUrl string, params url.Values, res any) error
- func Random(n int32) int32
- func RandomFloat(start float64, end float64) float64
- func RandomInt(min int, max int) int
- func StringPreIs(s string, prefix string) bool
- func StringToString(s string, split0 string, split1 string) string
- func ToSliceUint(s any, split string) ([]uint, error)
- func TruncateToTwoDecimal(num float64) float64
- func Validator(data any) error
- type Claims
- type Jwt
- type JwtConfig
- type Request
- type Response
- func (r *Response) AuthError(err error)
- func (r *Response) Error(err error)
- func (r *Response) ErrorMessage(message string)
- func (r *Response) LoginError(err error)
- func (r *Response) Response()
- func (r *Response) SetCode(code int)
- func (r *Response) SetData(data any)
- func (r *Response) SetMessage(message string)
- func (r *Response) Success(message string, data any)
Constants ¶
This section is empty.
Variables ¶
View Source
var Rules = map[string]string{
"custom": "",
"required": "^.+$",
"alpha": "^[a-zA-Z]+$",
"num": "^-?[0-9]+$",
"float": "^(-?\\d+)(\\.\\d+)?$",
"varName": "^[a-zA-Z][\\w]*$",
"alphaNum": "^[a-zA-Z0-9]+$",
"alphaNumUnline": "^[\\w]+$",
"alphaNumUnlineDash": "^[\\w\\-]+$",
"chs": "^[\u4e00-\u9fa5]+$",
"chsAlpha": "^[a-zA-Z\u4e00-\u9fa5]+$",
"chsAlphaNum": "^[a-zA-Z0-9\u4e00-\u9fa5]+$",
"chsAlphaNumUnline": "^[\\w\u4e00-\u9fa5]+$",
"chsAlphaNumUnlineDash": "^[\\w\\-\u4e00-\u9fa5]+$",
"mobile": "^1\\d{10}$",
"email": "^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\\.[a-zA-Z0-9_-]+)+$",
"postalCode": "^[1-9]\\d{5}$",
"idCard": "(^\\d{15}$)|(^\\d{18}$)|(^\\d{17}(\\d|X|x)$)",
"ip": "\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}",
"website": "https?://([\\S]+)\\.([\\S]+)",
"between": "",
"equal": "",
"in": "",
"len": "",
}
Functions ¶
func GetAgeFromStringDate ¶
GetAgeFromStringDate 从字符串日期直接计算年龄
Types ¶
type Claims ¶
type Claims struct {
ID int32 `json:"id"`
Type string `json:"type"`
jwt.RegisteredClaims
}
type Request ¶
func NewRequest ¶
type Response ¶
type Response struct {
Message string `json:"message"`
Code int `json:"code"`
Data any `json:"data"`
Writer http.ResponseWriter `json:"-"`
}
func NewResponse ¶
func NewResponse(w http.ResponseWriter) *Response
func (*Response) ErrorMessage ¶
func (*Response) LoginError ¶
func (*Response) SetMessage ¶
Source Files
¶
Click to show internal directories.
Click to hide internal directories.