Documentation ¶
Index ¶
- Constants
- Variables
- func CamelName(name string) string
- func CheckPasswordHash(password, hash string) bool
- func ContentDisposition(filename string, dispositionType ContentDispositionType) (disposition string)
- func Contract(separator string, strings ...string) (result string)
- func CopyFile(src, dst string) (copyFiles []string, err error)
- func CreateDir(dirName string) error
- func CreateFile(file string) error
- func DeleteFile(src string) (err error)
- func DirNotExistCreate(path string) (err error)
- func Flatten(nested map[string]interface{}, prefix string, style SeparatorStyle) (map[string]interface{}, error)
- func FlattenString(nestedStr, prefix string, style SeparatorStyle) (string, error)
- func GetAllFilesBy(pathName string, ty FileType) (allFiles []string, err error)
- func GetContentType(filepath string) (contentType string, err error)
- func GetDirFatherDeep(dir string) int
- func GetDirSonDeep(dir string) int
- func GetFileContentType(file *os.File) (contentType string, err error)
- func GetFileDir(filePath string) string
- func GetFilename(filePath string) string
- func GetFilenameWithExt(filePath string, ext string) (path string)
- func GetNeedDeleteFiles(src string) (deleteFiles []string, err error)
- func HashPassword(password string) (string, error)
- func HashPasswordWithCost(password string, cost int) (string, error)
- func InitialLowercase(from string) (to string)
- func IsDir(path string) (bool, error)
- func IsFileExist(filename string) bool
- func IsInArray(val interface{}, array interface{}) (exists bool, index int)
- func JSONInit(db *sql.DB, initializer JSONInitializer, table string, field string) (err error)
- func JSONString(obj interface{}) string
- func ListDir(src string) (infos []string, err error)
- func MapToStruct(model map[string]interface{}, obj interface{}) (err error)
- func Md5(from string) (to string, err error)
- func MoveFile(src, dst string) (err error)
- func MySQLJsonInit(table string, filed string, conditionFiled string, conditionValue interface{}, ...) (sql string, err error)
- func MySQLJsonUpdate(table string, filed string, conditionFiled string, conditionValue interface{}, ...) (sql string, err error)
- func MySQLJsonUpdateWithConfig(table string, filed string, conditionFiled string, conditionValue interface{}, ...) (sql string, err error)
- func NewPage(items interface{}, totalNum int64, perPage int, page int, ...) *pageData
- func NewPageExtra(key string, value interface{}) *extraPageData
- func ParsePackageName(domain string) (name string)
- func RandString(length int) string
- func RenameFile(src, dst string) error
- func RenderToFile(filename string, input string, data interface{}, isFile bool) (err error)
- func SearchString(slice []string, s string) int
- func StructToMap(obj interface{}) (model map[string]interface{}, err error)
- func SymmetricKey(bits uint) (key []byte, err error)
- func TruncateDay(t time.Time) time.Time
- func TruncateUnix(timestamp int64) int64
- func UnZip(zipFileName, destFileName string) (err error)
- func UnderscoreName(name string, upperInitial bool) string
- func ValidFilename(filename string) bool
- func ValidFilepath(filepath string) bool
- func Zip(destFileName string, zipFileNames ...string) (err error)
- type BaseStruct
- type BaseTag
- type BaseUser
- type CROS
- type Checksum
- type ChecksumType
- type Code
- type CodeError
- type CodeMessage
- type Connection
- type ContentDispositionType
- type CreatedStruct
- type Database
- type DeletedStruct
- type Duration
- type Elasticsearch
- type Error
- type ErrorCode
- type Field
- type FileSize
- type FileType
- type Http
- type HttpClient
- type HttpHeader
- type HttpMethod
- type HttpParameter
- type HttpParameterType
- type HttpPathParameter
- type HttpServer
- type Id
- func ParseBase2(id string) (Id, error)
- func ParseBase32(b []byte) (Id, error)
- func ParseBase36(id string) (Id, error)
- func ParseBase58(b []byte) (Id, error)
- func ParseBase64(id string) (Id, error)
- func ParseBytes(id []byte) (Id, error)
- func ParseInt64(id int64) Id
- func ParseIntBytes(id [8]byte) Id
- func ParseString(id string) (Id, error)
- func (f Id) Base2() string
- func (f Id) Base32() string
- func (f Id) Base36() string
- func (f Id) Base58() string
- func (f Id) Base64() string
- func (f Id) Bytes() []byte
- func (f Id) Int64() int64
- func (f Id) IntBytes() [8]byte
- func (f Id) MarshalJSON() ([]byte, error)
- func (f Id) Node() int64
- func (f Id) Step() int64
- func (f Id) String() string
- func (f Id) Time() int64
- func (f *Id) UnmarshalJSON(b []byte) error
- type IdStruct
- type Int64Slice
- type JSONFielder
- type JSONInitialized
- type JSONInitializer
- type JSONSyntaxError
- type Key
- type MapStruct
- type NamedTag
- type Paging
- type Proxy
- type ProxyScheme
- type Redis
- type SeparatorStyle
- type Snowflake
- type SoftDeleteStruct
- type Sorter
- type String
- type StringBuilder
- type StringSlice
- type Tagger
- type Timestamp
- func (t Timestamp) DayEnd() Timestamp
- func (t Timestamp) DayStart() Timestamp
- func (t Timestamp) DefaultTimeLayout() string
- func (t *Timestamp) GobDecode(data []byte) (err error)
- func (t Timestamp) GobEncode() ([]byte, error)
- func (t Timestamp) IsZero() bool
- func (t Timestamp) MarshalJSON() ([]byte, error)
- func (t Timestamp) Time() time.Time
- func (t *Timestamp) UnmarshalJSON(b []byte) error
- func (t *Timestamp) UnmarshalParam(src string) error
- type UpdatedStruct
- type Value
- type Weekday
Constants ¶
const ( // Http常用头 // HeaderAcceptLanguage 可接受的语言 HeaderAcceptLanguage = "Accept-Language" // HeaderContentType 请求数据类型 HeaderContentType = "Content-Scheme" // HeaderAuthorization 授权 HeaderAuthorization = "Authorization" // HeaderContentDisposition HeaderContentDisposition = "Content-disposition" // Http方法集合 // HttpMethodGet GET方法 HttpMethodGet HttpMethod = "GET" // HttpMethodPost POST方法 HttpMethodPost HttpMethod = "POST" // HttpMethodPut PUT方法 HttpMethodPut HttpMethod = "PUT" // HttpMethodDelete DELETE方法 HttpMethodDelete HttpMethod = "DELETE" // MethodPatch PATCH方法 HttpMethodPatch HttpMethod = "PATCH" // MethodHead HEAD方法 HttpMethodHead HttpMethod = "HEAD" // MethodOptions OPTIONS方法 HttpMethodOptions HttpMethod = "OPTIONS" )
Variables ¶
var ( // 文件相关 ErrOnCopySelf = &CodeError{ErrorCode: 1001, Message: "不能复制或者移动自身"} ErrSrcIsNotFile = &CodeError{ErrorCode: 1002, Message: "源文件不是文件"} // 密钥相关 ErrKeySize = &CodeError{ErrorCode: 2001, Message: "密钥位数有错,必须是8的倍数"} )
var ( // Separate nested key components with dots, e.g. "a.b.1.c.d" DotStyle = SeparatorStyle{Middle: "."} // Separate with path-like slashes, e.g. a/b/1/c/d PathStyle = SeparatorStyle{Middle: "/"} // Separate ala Rails, e.g. "a[b][c][1][d]" RailsStyle = SeparatorStyle{Before: "[", After: "]"} // Separate with underscores, e.g. "a_b_1_c_d" UnderscoreStyle = SeparatorStyle{Middle: "_"} )
Default styles
var ( // Epoch is set to the twitter snowflake epoch of Nov 04 2010 01:42:54 UTC in milliseconds // You may customize this to set a different epoch for your application. Epoch int64 = 1288834974657 // NodeBits holds the number of bits to use for Snowflake // Remember, you have a total 22 bits to share between Snowflake/Step NodeBits uint8 = 10 // StepBits holds the number of bits to use for Step // Remember, you have a total 22 bits to share between Snowflake/Step StepBits uint8 = 12 )
var ErrInvalidBase32 = errors.New("invalid base32")
ErrInvalidBase32 is returned by ParseBase32 when given an invalid []byte
var ErrInvalidBase58 = errors.New("invalid base58")
ErrInvalidBase58 is returned by ParseBase58 when given an invalid []byte
var NotValidInputError = errors.New("Not a valid input: map or slice")
Nested input must be a map or slice
var NotValidJsonInputError = errors.New("Not a valid input, must be a map")
JSON nested input must be a map
var WeekdayCN = []string{
"周日",
"周一",
"周二",
"周三",
"周四",
"周五",
"周六",
}
WeekdayCN 中文的星期几
Functions ¶
func CheckPasswordHash ¶
CheckPasswordHash 检查密码的正确性
func ContentDisposition ¶
func ContentDisposition(filename string, dispositionType ContentDispositionType) (disposition string)
ContentDisposition 解决附件下载乱码
func CreateFile ¶ added in v1.2.0
func DirNotExistCreate ¶ added in v1.2.0
DirNotExistCreate err为空存在,不会空则
func Flatten ¶
func Flatten(nested map[string]interface{}, prefix string, style SeparatorStyle) (map[string]interface{}, error)
Flatten generates a flat map from a nested one. The original may include values of type map, slice and scalar, but not struct. Keys in the flat map will be a compound of descending map keys and slice iterations. The presentation of keys is set by style. A prefix is joined to each key.
func FlattenString ¶
func FlattenString(nestedStr, prefix string, style SeparatorStyle) (string, error)
FlattenString generates a flat JSON map from a nested one. Keys in the flat map will be a compound of descending map keys and slice iterations. The presentation of keys is set by style. A prefix is joined to each key.
func GetAllFilesBy ¶ added in v1.2.0
func GetContentType ¶ added in v1.2.0
GetContentType 获得文件的ContentType
func GetDirFatherDeep ¶ added in v1.2.0
GetDirFatherDeep dir以/开头
func GetDirSonDeep ¶ added in v1.2.0
func GetFileContentType ¶ added in v1.2.0
GetFileContentType 获得文件的ContentType
func GetFilenameWithExt ¶ added in v1.2.7
GetFilenameWithExt 获得带扩展名的文件名
func GetNeedDeleteFiles ¶ added in v1.2.0
func HashPasswordWithCost ¶
HashPasswordWithCost 生成密码
func MapToStruct ¶
MapToStruct Map转换成结构体
func MySQLJsonInit ¶
func MySQLJsonInit( table string, filed string, conditionFiled string, conditionValue interface{}, initField string, initFieldValue interface{}, paths ...string, ) (sql string, err error)
MySQLJsonInit JSON初始化
func MySQLJsonUpdate ¶
func MySQLJsonUpdate( table string, filed string, conditionFiled string, conditionValue interface{}, data map[string]interface{}, ) (sql string, err error)
MySQLJsonUpdate 生成MySQL JSON增量更新SQL语句的快捷方式
func MySQLJsonUpdateWithConfig ¶
func MySQLJsonUpdateWithConfig( table string, filed string, conditionFiled string, conditionValue interface{}, data map[string]interface{}, prefix string, style SeparatorStyle, ) (sql string, err error)
MySQLJsonUpdateWithConfig 生成MySQL JSON增量更新SQL语句
func NewPage ¶
func NewPage(items interface{}, totalNum int64, perPage int, page int, extras ...extraPageData) *pageData
NewPage 生成新的分页数据对象
func NewPageExtra ¶ added in v1.2.27
func NewPageExtra(key string, value interface{}) *extraPageData
func ParsePackageName ¶
ParsePackageName 从域名解析出包名
func RenameFile ¶ added in v1.2.0
func RenderToFile ¶
RenderToFile 渲染模板到文件
func StructToMap ¶
StructToMap 结构体转换成Map
func TruncateUnix ¶
func ValidFilename ¶ added in v1.2.0
ValidFilename 有效文件名(Windows标准)
Types ¶
type BaseStruct ¶
type BaseStruct struct { IdStruct `xorm:"extends"` CreatedStruct `xorm:"extends"` UpdatedStruct `xorm:"extends"` }
BaseStruct 基础数据库模型
type BaseUser ¶
type BaseUser struct { BaseStruct `xorm:"extends"` // 用户名 Username String `xorm:"varchar(32) notnull default('') unique(uidx_name)" json:"username" validate:"omitempty,min=1,max=32,email"` // 手机号 // 类似于+86-17089792784 Phone String `xorm:"varchar(15) notnull default('') unique(uidx_phone)" json:"phone" validate:"omitempty,mobile"` // 密码 Pwd string `xorm:"varchar(512) notnull default('')" json:"-"` }
基础用户数据
type CROS ¶ added in v1.2.0
type CROS struct { AllowOrigins []string `default:"['*']" yaml:"allowOrigins"` AllowCredentials bool `default:"true" yaml:"allowCredentials"` }
CROS 跨域配置
type Checksum ¶
type Checksum struct { // Sum 校验字符串 Sum string `json:"sum" validate:"required"` // Type 类型 Type ChecksumType `json:"type" validate:"required,oneof=crc32 crc64 sha1 sha256"` }
Checksum 数据校验
type ChecksumType ¶
type ChecksumType string
ChecksumType 数据校验合类型
const ( // ChecksumTypeCrc32 Crc32 ChecksumTypeCrc32 ChecksumType = "crc32" // ChecksumTypeCrc64 Crc64 ChecksumTypeCrc64 ChecksumType = "crc64" // ChecksumTypeSha1 Crc64 ChecksumTypeSha1 ChecksumType = "sha1" // ChecksumTypeSha256 Crc64 ChecksumTypeSha256 ChecksumType = "sha256" )
type CodeError ¶ added in v1.2.0
type CodeError struct { // ErrorCode 错误码 ErrorCode ErrorCode `json:"errorCode"` // Message 消息 Message string `json:"message"` // Data 数据 Data interface{} `json:"data"` }
CodeError 带错误编号和消息的错误
func NewCodeError ¶ added in v1.2.0
NewCodeError 创建错误
func (*CodeError) ToErrorCode ¶ added in v1.2.0
type CodeMessage ¶
type CodeMessage struct { // Code 消息代码 Code Code `json:"code"` // Title 消息标题 // 通常是模板字符串 Title *string `json:"title"` // Text 消息内容 // 通常是模板字符串 Text *string `json:"text,omitempty"` }
CodeMessage 带消息代码的消息
func NewCodeMessage ¶
func NewCodeMessage(code Code, title, text string) *CodeMessage
NewCodeMessage 创建消息
func (CodeMessage) ParseText ¶
func (cm CodeMessage) ParseText(params ...interface{}) CodeMessage
ParseText 格式化输出Text,并返回新的消息对象
func (CodeMessage) ParseTitle ¶
func (cm CodeMessage) ParseTitle(params ...interface{}) CodeMessage
ParseTitle 格式化输出Title,并返回新的消息对象
type Connection ¶ added in v1.2.11
type Connection struct { // MaxOpen 最大打开连接数 MaxOpen int `default:"150" yaml:"maxOpen" json:"maxOpen"` // MaxIdle 最大休眠连接数 MaxIdle int `default:"30" yaml:"maxIdle" json:"maxIdle"` // MaxLifetime 每个连接最大存活时间 MaxLifetime time.Duration `default:"5s" yaml:"maxLifetime" json:"maxLifetime"` }
Connection 连接池配置
type ContentDispositionType ¶
type ContentDispositionType string
ContentDispositionType 下载类型
const ( // ContentDispositionTypeAttachment 附件下载 ContentDispositionTypeAttachment ContentDispositionType = "attachment" // ContentDispositionTypeInline 浏览器直接打开 ContentDispositionTypeInline ContentDispositionType = "inline" )
type CreatedStruct ¶
type CreatedStruct struct { // CreatedAt 创建时间 CreatedAt Timestamp `xorm:"created default('2020-02-04 09:55:52')" json:"createdAt"` }
CreatedStruct 带创建时间模型
type Database ¶ added in v1.2.0
type Database struct { // Type 数据库类型,支持 Type string `default:"sqlite3"` Address string `default:"127.0.0.1:3306"` Username string Password string Protocol string `default:"tcp"` // Connection 连接池配置 Connection Connection Suffix string Prefix string Schema string `default:"schema"` MigrationTableName string `default:"migration"` Parameters string Path string `default:"data.db"` }
Database 数据库配置
type DeletedStruct ¶
type DeletedStruct struct { // DeletedAt 删除时间,用户软删除 DeletedAt Timestamp `xorm:"deleted default('2020-02-04 09:55:52')" json:"deletedAt"` }
DeletedStruct 软删除模型
type Duration ¶
Duration 弥补标准库不能使用ParseDuration
func (*Duration) UnmarshalJSON ¶
UnmarshalJSON 解析JSON
type Elasticsearch ¶ added in v1.3.4
type Elasticsearch struct { // Address 地址 Address string `yaml:"address" validate:"required,uri"` // Username 用户名 Username string `yaml:"username"` // Password 密码 Password string `yaml:"password"` }
Elasticsearch 配置
type Error ¶ added in v1.2.0
type Error interface { // ToErrorCode 返回错误码 ToErrorCode() ErrorCode // ToMessage 返回错误消息 ToMessage() string // ToData 返回错误实体 // 在某些错误下,可能需要返回额外的信息给前端处理 // 比如,认证错误,需要返回哪些字段有错误 ToData() interface{} }
Error 接口,符合条件的错误统一处理
type Http ¶ added in v1.3.5
type Http struct { // Server 服务器配置 Server HttpServer `json:"server" yaml:"server"` // Client 客户端配置 Client HttpClient `json:"client" yaml:"client"` }
Http Http配置
type HttpClient ¶ added in v1.3.5
type HttpClient struct { // Timeout 超时 Timeout time.Duration `json:"timeout" yaml:"timeout"` // Proxy 代理 Proxy Proxy `json:"proxy" yaml:"proxy"` }
HttpClient Http客户端配置
type HttpHeader ¶
type HttpHeader struct {
// contains filtered or unexported fields
}
HttpHeader Http请求头
func NewHttpHeader ¶
func NewHttpHeader(key string, value string) *HttpHeader
NewHttpHeader 创建一个Http请求头
func (*HttpHeader) Key ¶
func (hh *HttpHeader) Key() string
func (*HttpHeader) Type ¶
func (hh *HttpHeader) Type() HttpParameterType
func (*HttpHeader) Value ¶
func (hh *HttpHeader) Value() string
type HttpParameter ¶
type HttpParameter interface { // Type 类型 Type() HttpParameterType // Key 键 Key() string // Value 值 Value() string }
HttpParameter Http额外参数接口
type HttpParameterType ¶
type HttpParameterType string
HttpParameterType Http额外参数类型
const ( // ContentDispositionTypeHeader 请求头 HttpParameterTypeHeader HttpParameterType = "header" // ContentDispositionTypePathParameter 路径参数 HttpParameterTypePathParameter HttpParameterType = "path" )
type HttpPathParameter ¶
type HttpPathParameter struct {
// contains filtered or unexported fields
}
HttpPathParameter Http路径参数
func NewHttpPathParameter ¶
func NewHttpPathParameter(key string, value string) *HttpPathParameter
NewHttpPathParameter 创建一个Http路径参数
func (*HttpPathParameter) Key ¶
func (hh *HttpPathParameter) Key() string
func (*HttpPathParameter) Type ¶
func (hh *HttpPathParameter) Type() HttpParameterType
func (*HttpPathParameter) Value ¶
func (hh *HttpPathParameter) Value() string
type HttpServer ¶ added in v1.3.5
type HttpServer struct { // Ip 监听的地址 Ip string `default:""` // Port 监听的端口 Port int `default:"21323"` // BasePath 前缀地址 BasePath string `yaml:"basePath"` // CROS 跨域配置 CROS CROS }
HttpServer Http服务器配置
type Id ¶
type Id int64
An Id is a custom type used for a snowflake Id. This is used so we can attach methods onto the Id.
func ParseBase2 ¶ added in v1.2.0
ParseBase2 converts a Base2 string into a snowflake Id
func ParseBase32 ¶ added in v1.2.0
ParseBase32 parses a base32 []byte into a snowflake Id NOTE: There are many different base32 implementations so becareful when doing any interoperation.
func ParseBase36 ¶ added in v1.2.0
ParseBase36 converts a Base36 string into a snowflake Id
func ParseBase58 ¶ added in v1.2.0
ParseBase58 parses a base58 []byte into a snowflake Id
func ParseBase64 ¶
ParseBase64 converts a base64 string into a snowflake Id
func ParseBytes ¶
ParseBytes converts a byte slice into a snowflake Id
func ParseIntBytes ¶
ParseIntBytes converts an array of bytes encoded as big endian integer as a snowflake Id
func ParseString ¶
ParseString converts a string into a snowflake Id
func (Id) Base32 ¶ added in v1.2.0
Base32 uses the z-base-32 character set but encodes and decodes similar to base58, allowing it to create an even smaller result string. NOTE: There are many different base32 implementations so becareful when doing any interoperation.
func (Id) IntBytes ¶
IntBytes returns an array of bytes of the snowflake Id, encoded as a big endian integer.
func (Id) MarshalJSON ¶
MarshalJSON returns a json byte array string of the snowflake Id.
func (*Id) UnmarshalJSON ¶
UnmarshalJSON converts a json byte array of a snowflake Id into an Id type.
type IdStruct ¶
type IdStruct struct { // Id 编号 Id int64 `xorm:"pk notnull unique index('idx_id') default(0)" json:"id,string"` }
IdStruct 带序列号的模型
type Int64Slice ¶ added in v1.2.0
type Int64Slice []int64
func (*Int64Slice) FromDB ¶ added in v1.2.0
func (s *Int64Slice) FromDB(bytes []byte) error
func (Int64Slice) MarshalJSON ¶ added in v1.2.0
func (s Int64Slice) MarshalJSON() ([]byte, error)
func (Int64Slice) ToDB ¶ added in v1.2.0
func (s Int64Slice) ToDB() ([]byte, error)
func (*Int64Slice) UnmarshalJSON ¶ added in v1.2.0
func (s *Int64Slice) UnmarshalJSON(bytes []byte) error
func (*Int64Slice) UnmarshalParam ¶ added in v1.2.0
func (s *Int64Slice) UnmarshalParam(src string) error
type JSONFielder ¶
type JSONFielder interface { // InitializeField 初始化字段 InitializeField() string }
JSONFielder JSON字段
type JSONInitialized ¶
type JSONInitialized struct { // Initialized 是否初始化 Initialized bool `json:"initialized,omitempty"` }
JSONInitialized JSON是否初始化
func (JSONInitialized) InitializeField ¶
func (ji JSONInitialized) InitializeField() string
func (JSONInitialized) IsInitialized ¶
func (ji JSONInitialized) IsInitialized() bool
type JSONInitializer ¶
type JSONInitializer interface { // InitSQL 初始化SQL InitSQL(table string, field string) (string, error) // IsInitialized 是否已经初始化完成 IsInitialized() bool }
JSONInitializer JSON初始化者
type JSONSyntaxError ¶
type JSONSyntaxError struct {
// contains filtered or unexported fields
}
A JSONSyntaxError is returned from UnmarshalJSON if an invalid Id is provided.
func (JSONSyntaxError) Error ¶
func (j JSONSyntaxError) Error() string
type MapStruct ¶
type MapStruct interface { // ToMap 转换成Map StructToMap() (model map[string]interface{}, err error) // 转换成结构体 MapToStruct(model map[string]interface{}) (err error) }
MapStruct Map和结构体转换
type NamedTag ¶
type NamedTag struct { BaseTag // contains filtered or unexported fields }
NamedTag 描述Golang的Tag标记
type Paging ¶
type Paging struct { // 当前页 Page int `default:"1" json:"page" validate:"min=1"` // 每页个数 PerPage int `default:"20" json:"perPage" validate:"min=1"` // 查询关键字 Keyword string `json:"keyword"` // 排序顺序 SortOrder string `default:"DESC" json:"sortOrder" validate:"oneof=asc ASC ascending ASCENDING desc DESC descending DESCENDING"` }
Paging 分页对象
type Proxy ¶ added in v1.3.5
type Proxy struct { // Host 主机(可以是Ip或者域名) Host string `json:"ip" yaml:"ip" validate:"required"` // Port 端口 Port int `default:"80" json:"port" yaml:"port" validate:"required"` // Scheme 代理类型 Scheme ProxyScheme `default:"scheme" json:"scheme" yaml:"type" validate:"required,oneof=socks4 socks5 http https"` // Username 代理认证用户名 Username string `json:"username" yaml:"username"` // Password 代理认证密码 Password string `json:"password" yaml:"password"` }
Proxy 代理配置
type ProxyScheme ¶ added in v1.3.6
type ProxyScheme string
ProxyScheme 代理类型
const ( // ProxyTypeSocksV4 Socks代码 ProxyTypeSocksV4 ProxyScheme = "socks4" // ProxyTypeSocksV5 Socks代码 ProxyTypeSocksV5 ProxyScheme = "socks4" // ProxyTypeSocksV4 Socks代码 ProxyTypeHttp ProxyScheme = "http" // ProxyTypeSocksV4 Socks代码 ProxyTypeHttps ProxyScheme = "https" )
type Redis ¶ added in v1.2.33
type Redis struct { // Addr 通信地址 Addr string `default:"127.0.0.1:6379" validate:"required"` // Password 授权密码 Password string // DB 数据库 DB int `default:"0"` }
Redis Redis配置
type SeparatorStyle ¶
type SeparatorStyle struct { Before string // Prepend to key Middle string // Add between keys After string // Append to key }
The style of keys. If there is an input with two nested keys "f" and "g", with "f" at the root,
{ "f": { "g": ... } }
the output will be the concatenation
f{Middle}{Before}g{After}...
Any struct element may be blank. If you use Middle, you will probably leave Before & After blank, and vice-versa. See examples in flatten_test.go and the "Default styles" here.
type Snowflake ¶
type Snowflake struct {
// contains filtered or unexported fields
}
A Snowflake struct holds the basic information needed for a snowflake generator node
func NewSnowflake ¶
NewSnowflake returns a new snowflake node that can be used to generate snowflake IDs
type SoftDeleteStruct ¶
type SoftDeleteStruct struct { BaseStruct `xorm:"extends"` DeletedStruct `xorm:"extends"` }
SoftDeleteStruct 带软删除功能的数据库模型
type StringBuilder ¶ added in v1.2.0
StringBuilder 内嵌bytes.StringBuilder,支持连写
func NewStringBuilder ¶ added in v1.2.0
func NewStringBuilder() *StringBuilder
func (*StringBuilder) Append ¶ added in v1.2.0
func (b *StringBuilder) Append(i interface{}) *StringBuilder
type StringSlice ¶
type StringSlice []string
func (*StringSlice) UnmarshalParam ¶
func (ss *StringSlice) UnmarshalParam(src string) error
type Timestamp ¶
Timestamp 时间戳
func ParseTimestamp ¶
ParseTimestamp 从Time对象生成Timestamp
func (Timestamp) DefaultTimeLayout ¶
DefaultTimeLayout 按默认时间布局转换为字符串
func (Timestamp) MarshalJSON ¶
MarshalJSON 序列化成JSON时调用
func (*Timestamp) UnmarshalJSON ¶
UnmarshalJSON 反序列化成JSON时调用
func (*Timestamp) UnmarshalParam ¶
UnmarshalParam 从Echo参数转换
type UpdatedStruct ¶
type UpdatedStruct struct { // UpdatedAt 最后更新时间 UpdatedAt Timestamp `xorm:"updated default('2020-02-04 09:55:52')" json:"updatedAt"` }
UpdatedStruct 带修改时间模型
Source Files ¶
- array.go
- checksum.go
- cros.go
- database.go
- database_json.go
- database_string.go
- elasticsearch.go
- encrypt.go
- error.go
- error_var.go
- field.go
- file.go
- file_copy.go
- file_size.go
- flatten.go
- http.go
- http_client.go
- http_header.go
- http_path_parameter.go
- http_server.go
- int64_slice.go
- json.go
- key.go
- mapstructure.go
- message.go
- paging.go
- password.go
- proxy.go
- redis.go
- snowflake.go
- string.go
- string_parse.go
- string_rand.go
- string_slice.go
- struct.go
- tag.go
- template.go
- time.go
- user.go
- value.go
- zip.go