Documentation
¶
Index ¶
- Constants
- func AddDir(path string) error
- func AddFile(path string) error
- func AddFileIfNotExists(path string) error
- func AssignIfNotNil[T any](dst *T, src *T)
- func GenerateRandomString(length int) string
- func GetRealClientIP(r *http.Request) string
- func IsExpired(lastTime time.Time, duration time.Duration) bool
- func IsWithinDuration(lastTime time.Time, duration time.Duration) bool
- func JoinInt64s(nums []int64) string
- func NewCache() *cache
- func ParamToInt64(c *gin.Context, key string) (int64, error)
- func StructToMap(obj interface{}) map[string]string
- type Cache
- type Time
- type TreeService
Constants ¶
View Source
const (
DefaultTimeFormat = time.DateTime
)
Variables ¶
This section is empty.
Functions ¶
func AddFileIfNotExists ¶
AddFileIfNotExists add file if not exists
func GenerateRandomString ¶
GenerateRandomString 生成指定长度的随机字符串
func IsWithinDuration ¶
IsWithinDuration 检查时间是否在指定时间段内
func ParamToInt64 ¶
ParamToInt64 从 URL 参数中获取 int64 类型的值.
func StructToMap ¶
StructToMap converts a struct to a map
Types ¶
type Cache ¶
type Cache interface {
Get(ctx context.Context, key string) (string, error)
Set(ctx context.Context, key string, value string, expiration time.Duration) error
Delete(ctx context.Context, key string) error
Close()
}
Cache 缓存接口
type Time ¶
func (*Time) UnmarshalJSON ¶
UnmarshalJSON 格式化自定义时间转换为 time.Time
type TreeService ¶
type TreeService struct {
PrimaryKey string
ParentKey string
ExpandedKey string
LeafKey string
ChildrenKey string
Expanded bool
Result []map[string]interface{}
Level map[interface{}]int
}
TreeService is a service for tree data.
func NewTreeService ¶
func NewTreeService(config TreeService) *TreeService
NewTreeService returns a new TreeService.
func (*TreeService) MakeTree ¶
func (t *TreeService) MakeTree(data []map[string]interface{}) []map[string]interface{}
MakeTree is a function for make tree data.
@param data is a data for make tree. @return a tree data.
func (*TreeService) MakeTreeForHTML ¶
func (t *TreeService) MakeTreeForHTML(data []map[string]interface{}) []map[string]interface{}
MakeTreeForHTML 生成线性结构, 便于HTML输出, 参数同上.
Click to show internal directories.
Click to hide internal directories.