pocket

package module
v0.0.0-...-35d3e90 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2021 License: MIT Imports: 25 Imported by: 0

README

pocket

Documentation

Overview

Package pocket Create at 2020-11-06 10:17

Package pocket Create at 2020-11-06 10:23

Package pocket Create at 2021-01-29 10:17

Package pocket Create at 2020-11-25 10:08

Package pocket Create at 2020-11-06 10:18

Package kit Create at 2020-12-01 11:11

Package kit Create at 2020-11-06 10:20

Package pocket Create at 2020-12-01 11:35

Package pocket Create at 2020-11-06 10:20

Index

Constants

This section is empty.

Variables

View Source
var DefaultLogger = &Logback{
	logger: log.New(os.Stdout, "", defaultFlag),
	fields: nil,
	level:  InfoLevel,
}

Functions

func CreateNumberCaptcha

func CreateNumberCaptcha(digit int) string

CreateNumberCaptcha random

func DecodeQuery

func DecodeQuery(dst interface{}, src map[string][]string) error

DecodeQuery decode get query

func Export

func Export(sheets []Sheet) (*bytes.Buffer, error)

Export export excel

func FloatMax

func FloatMax(a, b float64) float64

FloatMax float max

func FloatMin

func FloatMin(a, b float64) float64

FloatMin float min

func GetDay

func GetDay(t time.Time) int

GetDay day of given time

func GetDaysOfMonth

func GetDaysOfMonth(year int, month int) (days int)

GetDaysOfMonth days in month

func GetDaysOfMonthByTime

func GetDaysOfMonthByTime(t time.Time) (days int)

GetDaysOfMonthByTime days in month

func GetMonth

func GetMonth(t time.Time) int

GetMonth month of given time

func GetUUID

func GetUUID() uuid.UUID

GetUUID gene uuid

func GetUUIDStr

func GetUUIDStr() string

GetUUIDStr gene uuid

func GetYear

func GetYear(t time.Time) int

GetYear year of given time

func HexStr2Uint16

func HexStr2Uint16(s string) (uint16, error)

HexStr2Uint16 hex string to uint16

func HexStr2Uint32

func HexStr2Uint32(s string) (uint32, error)

HexStr2Uint32 hex string to uint32

func HexStr2Uint64

func HexStr2Uint64(s string) (uint64, error)

HexStr2Uint64 hex string to uint64

func Import

func Import(reader io.Reader, sheets map[string]Sheet) error

Import import excel

func IntMax

func IntMax(a, b int64) int64

IntMax int max

func IntMin

func IntMin(a, b int64) int64

IntMin int min

func ListAllFiles

func ListAllFiles(path string) ([]string, error)

func Md5

func Md5(txt string) string

md5 md5 32 lowercase

func Pow

func Pow(x, n int64) int64

Pow 次方

func SnakeString

func SnakeString(s string) string

SnakeString, XxYy to xx_yy , XxYY to xx_yy

func SonyFlakeId

func SonyFlakeId() (uint64, error)

SonyFlakeId SonyFlake id

func UnixMillisecond

func UnixMillisecond() int64

UnixMillisecond unix time millisecond

func UnixSecond

func UnixSecond() int64

UnixSecond unix time second

func Utf8Index

func Utf8Index(str, substr string) int

Utf8Index Index returns the index of the first instance of substr in s, or -1 if substr is not present in s

func XormUpdateParam

func XormUpdateParam(model interface{}) (map[string]interface{}, error)

Types

type Api

type Api interface {
	Info(v ...interface{})
	Debug(v ...interface{})
	Warn(v ...interface{})
	Error(v ...interface{})
	Trace(v ...interface{})
}

type Column

type Column struct {
	Width        float64 // 单元格宽度
	Merge        bool    // 是否合并
	MergeExclude string  // 合并排除
	Style        string  // 单元格样式,覆盖Sheet的ContentStyle
	// contains filtered or unexported fields
}

Column 单元格设置

type Fields

type Fields map[string]interface{}

type Format

type Format interface {
	// contains filtered or unexported methods
}

Format format value

type Formatter

type Formatter struct {
	Enum string `schema:"enum"`
	Time string `schema:"time"`
}

Formatter data formatter

type Level

type Level uint32

Level type

const (
	// PanicLevel level, highest level of severity. Logs and then calls panic with the
	// message passed to Debug, Info, ...
	PanicLevel Level = iota
	// FatalLevel level. Logs and then calls `logger.Exit(1)`. It will exit even if the
	// logging level is set to Panic.
	FatalLevel
	// ErrorLevel level. Logs. Used for errors that should definitely be noted.
	// Commonly used for hooks to send errors to an error tracking service.
	ErrorLevel
	// WarnLevel level. Non-critical entries that deserve eyes.
	WarnLevel
	// InfoLevel level. General operational entries about what's going on inside the
	// application.
	InfoLevel
	// DebugLevel level. Usually only enabled when debugging. Very verbose logging.
	DebugLevel
	// TraceLevel level. Designates finer-grained informational events than the Debug.
	TraceLevel
)

type Logback

type Logback struct {
	// contains filtered or unexported fields
}

func (*Logback) Debug

func (logback *Logback) Debug(v ...interface{})

func (*Logback) Error

func (logback *Logback) Error(v ...interface{})

func (*Logback) Info

func (logback *Logback) Info(v ...interface{})

func (*Logback) SetLevel

func (logback *Logback) SetLevel(level Level)

func (*Logback) SetOutput

func (logback *Logback) SetOutput(w io.Writer)

func (*Logback) Trace

func (logback *Logback) Trace(v ...interface{})

func (*Logback) Warn

func (logback *Logback) Warn(v ...interface{})

func (*Logback) WithFields

func (logback *Logback) WithFields(fields Fields) *Logback

type RedisConfig

type RedisConfig struct {
	Host       string
	Pwd        string
	ExpireTime int
}

RedisConfig redis config

type RedisUtils

type RedisUtils struct {
	Client *redis.Client
	// contains filtered or unexported fields
}

func NewRedis

func NewRedis(config RedisConfig) (*RedisUtils, error)

NewRedis get redis client

func (*RedisUtils) Close

func (r *RedisUtils) Close()

Close close redis connect

type Sheet

type Sheet struct {
	Name         string            `json:"name"`              // sheet 名称
	T            reflect.Type      `json:"-"`                 // 列的类型
	Result       *[]interface{}    `json:"result,omitempty"`  // 导入结果
	Content      []interface{}     `json:"content,omitempty"` // 导出数据
	HeaderStyle  string            `json:"-"`                 // 头部单元格样式
	ContentStyle string            `json:"-"`                 // 内容单元格样式
	Panes        []string          `json:"-"`
	Columns      map[string]Column `json:"-"` // 内容单元格详细设置
}

Sheet 表

type SqlBuilder

type SqlBuilder struct {
	Table string
	Model interface{}
	Cond  interface{}
}

func NewSqlBuilder

func NewSqlBuilder(table string, model interface{}) *SqlBuilder

NewSqlBuilder sql builder tag规则 `db:"column,add,set,sort"`

func (*SqlBuilder) BuildInsert

func (builder *SqlBuilder) BuildInsert() (string, []interface{}, error)

BuildInsert 生成批量插入sql

func (*SqlBuilder) BuildInsertRow

func (builder *SqlBuilder) BuildInsertRow() (string, []interface{}, error)

BuildInsertRow 生成单条插入sql

func (*SqlBuilder) Condition

func (builder *SqlBuilder) Condition(c interface{}) *SqlBuilder

BuildInsertRow 生成单条插入sql

Jump to

Keyboard shortcuts

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