Documentation
¶
Index ¶
- Variables
- func AllowRead(path string) bool
- func AllowWrite(path string) bool
- func Copy(dstFileName, srcFileName string) (w int64, err error)
- func CopyDir(dst string, src string) (err error)
- func CurrentDir() string
- func CurrentExePath() string
- func Exist(path string) bool
- func FileModTime(path string) (int64, error)
- func FileName(path string) string
- func FileNameDir(path string) string
- func FileNameExt(path string) string
- func FileNameNoExt(path string) string
- func FileSize(path string) (int64, error)
- func GetFileListBySuffix(dirPath, suffix string) (files []string, err error)
- func GetFileListJustCurrentDirBySuffix(dirPath string, suffix string) (files []string, err error)
- func HumaneFileSize(s uint64) string
- func IncludeElement(list interface{}, element interface{}) (ok, found bool)
- func Init(option IOption)
- func IsContain(items []string, item interface{}) bool
- func IsDir(path string) bool
- func IsEmpty(object interface{}) bool
- func IsFile(path string) bool
- func IsNil(object interface{}) bool
- func NewDBStruct() *dbStruct
- func NewStack() *stack
- func ObjectsAreEqual(expected, actual interface{}) bool
- func ObjectsAreEqualValues(expected, actual interface{}) bool
- func PB(b bool) *bool
- func PF64(f float64) *float64
- func PI64(i int64) *int64
- func PS(s string) *string
- func PT(t time.Time) *time.Time
- func RowBounds(offset, limit int64) *rowBounds
- func SetLogger(log ILogger)
- func SqlInParam(object interface{}) (string, []interface{})
- func SubString(s string, pos, length int) string
- func ToInt64(value interface{}) (d int64, err error)
- func WriteAppend(path string, b []byte) error
- func WriteAt(path string, b []byte, off int64) error
- type DB
- func (d *DB) Begin() (*TX, error)
- func (d *DB) BeginTx(ctx context.Context, opts *sql.TxOptions) (*TX, error)
- func (g *DB) Close() error
- func (g *DB) Delete(stmt string, param interface{}) (int64, error)
- func (g *DB) DeleteContext(ctx context.Context, stmt string, param interface{}) (int64, error)
- func (g *DB) DeleteDynamic(stmt, sql string, param interface{}) (affected int64, err error)
- func (g *DB) ExecRaw(sql string, params map[string]interface{}) (int64, error)
- func (g *DB) Insert(stmt string, param interface{}) (int64, int64, error)
- func (g *DB) InsertContext(ctx context.Context, stmt string, param interface{}) (int64, int64, error)
- func (g *DB) InsertDynamic(stmt, sql string, param interface{}) (lastInsertId int64, affected int64, err error)
- func (g *DB) QueryRaw(sql string, params map[string]interface{}, resultType ResultType) func(res interface{}) error
- func (g *DB) Select(stmt string, param interface{}, rowBound ...*rowBounds) func(res interface{}) (int64, error)
- func (g *DB) SelectContext(ctx context.Context, stmt string, param interface{}, rowBound ...*rowBounds) func(res interface{}) (int64, error)
- func (g *DB) SelectDynamic(stmt, sql string, param interface{}, resultType ResultType, ...) func(res interface{}) (int64, error)
- func (g *DB) SelectPage(stmt string, param interface{}, pageRows, offset int64) func(res interface{}, num interface{}) error
- func (d *DB) Transaction(fn func(tx *TX) error) error
- func (d *DB) TransactionTX(ctx context.Context, opts *sql.TxOptions, fn func(tx *TX) error) error
- func (g *DB) Update(stmt string, param interface{}) (int64, error)
- func (g *DB) UpdateContext(ctx context.Context, stmt string, param interface{}) (int64, error)
- func (g *DB) UpdateDynamic(stmt, sql string, param interface{}) (affected int64, err error)
- type DBConfig
- type DBConfigBuilder
- func (d *DBConfigBuilder) Build() *DBConfig
- func (d *DBConfigBuilder) DB(db map[string]*GoBatisDB) *DBConfigBuilder
- func (d *DBConfigBuilder) DS(dss []*DataSource) *DBConfigBuilder
- func (d *DBConfigBuilder) Mappers(mappers []string) *DBConfigBuilder
- func (d *DBConfigBuilder) ShowSQL(showSQL bool) *DBConfigBuilder
- type DBOption
- type DBType
- type DSOption
- type DataSource
- type DataSourceBuilder
- func (d *DataSourceBuilder) Build() *DataSource
- func (d *DataSourceBuilder) DataSource(ds string) *DataSourceBuilder
- func (d *DataSourceBuilder) DataSourceName(dsn string) *DataSourceBuilder
- func (d *DataSourceBuilder) DriverName(dn string) *DataSourceBuilder
- func (d *DataSourceBuilder) MaxIdleConns(mic int) *DataSourceBuilder
- func (d *DataSourceBuilder) MaxLifeTime(mlt int) *DataSourceBuilder
- func (d *DataSourceBuilder) MaxOpenConns(moc int) *DataSourceBuilder
- type ElemType
- type FileOption
- type FmtMode
- type GoBatis
- type GoBatisDB
- type ILogger
- type IOption
- type LogLevel
- type NullBool
- type NullFloat64
- type NullInt64
- type NullString
- type NullTime
- type OptionType
- type OutType
- type ResultType
- type TX
- func (g *TX) Close() error
- func (t *TX) Commit() error
- func (g *TX) Delete(stmt string, param interface{}) (int64, error)
- func (g *TX) DeleteContext(ctx context.Context, stmt string, param interface{}) (int64, error)
- func (g *TX) DeleteDynamic(stmt, sql string, param interface{}) (affected int64, err error)
- func (g *TX) ExecRaw(sql string, params map[string]interface{}) (int64, error)
- func (g *TX) Insert(stmt string, param interface{}) (int64, int64, error)
- func (g *TX) InsertContext(ctx context.Context, stmt string, param interface{}) (int64, int64, error)
- func (g *TX) InsertDynamic(stmt, sql string, param interface{}) (lastInsertId int64, affected int64, err error)
- func (g *TX) QueryRaw(sql string, params map[string]interface{}, resultType ResultType) func(res interface{}) error
- func (t *TX) Rollback() error
- func (g *TX) Select(stmt string, param interface{}, rowBound ...*rowBounds) func(res interface{}) (int64, error)
- func (g *TX) SelectContext(ctx context.Context, stmt string, param interface{}, rowBound ...*rowBounds) func(res interface{}) (int64, error)
- func (g *TX) SelectDynamic(stmt, sql string, param interface{}, resultType ResultType, ...) func(res interface{}) (int64, error)
- func (g *TX) SelectPage(stmt string, param interface{}, pageRows, offset int64) func(res interface{}, num interface{}) error
- func (g *TX) Update(stmt string, param interface{}) (int64, error)
- func (g *TX) UpdateContext(ctx context.Context, stmt string, param interface{}) (int64, error)
- func (g *TX) UpdateDynamic(stmt, sql string, param interface{}) (affected int64, err error)
- type Tag
Constants ¶
This section is empty.
Variables ¶
var PARAMETER_SEPARATORS = [19]string{`"`, `\'`, `:`, `&`, `,`, `;`, `(`, `)`, `|`, `=`, `+`, `-`, `*`, `%`, `/`, `\\`, `<`, `>`, `^`}
Functions ¶
func Copy ¶ added in v0.1.15
复制文件,目标文件所在目录不存在,则创建目录后再复制 Copy(`d:\test\hello.txt`,`c:\test\hello.txt`)
func CurrentDir ¶ added in v0.1.15
func CurrentDir() string
获得程序所在当前文件路径 注意末尾不包含/ d:\test\hello.exe ==> d:\test
func CurrentExePath ¶ added in v0.1.15
func CurrentExePath() string
获取可执行文件的绝对路径(包括文件名) d:\test\hello.exe
func FileNameExt ¶ added in v0.1.15
返回文件的后缀名 c:\test\hello.txt ==> .txt
func FileNameNoExt ¶ added in v0.1.15
获取无后缀的文件名 c:\test\hello.txt ==> hello
func GetFileListBySuffix ¶ added in v0.1.15
遍历目录及下级目录,查找符合后缀文件,如果suffix为空,则查找所有文件 如果后缀为空,则查找任何后缀的文件
func GetFileListJustCurrentDirBySuffix ¶ added in v0.1.15
遍历指定目录下的所有文件,查找符合后缀文件,不进入下一级目录搜索 如果后缀为空,则查找任何后缀的文件
func HumaneFileSize ¶ added in v0.1.15
把文件大小转换成人更加容易看懂的文本 HumaneFileSize calculates the file size and generate user-friendly string.
func IncludeElement ¶ added in v0.1.15
func IncludeElement(list interface{}, element interface{}) (ok, found bool)
containsElement try loop over the list check if the list includes the element. return (false, false) if impossible. return (true, false) if element was not found. return (true, true) if element was found.
func IsEmpty ¶ added in v0.1.15
func IsEmpty(object interface{}) bool
isEmpty gets whether the specified object is considered empty or not.
func IsNil ¶ added in v0.1.15
func IsNil(object interface{}) bool
isNil checks if a specified object is nil or not, without Failing.
func NewDBStruct ¶ added in v0.1.23
func NewDBStruct() *dbStruct
func ObjectsAreEqual ¶ added in v0.1.15
func ObjectsAreEqual(expected, actual interface{}) bool
ObjectsAreEqual determines if two objects are considered equal.
This function does no assertion of any kind.
func ObjectsAreEqualValues ¶ added in v0.1.15
func ObjectsAreEqualValues(expected, actual interface{}) bool
ObjectsAreEqualValues gets whether two objects are equal, or if their values are equal.
func SqlInParam ¶ added in v0.1.15
func SqlInParam(object interface{}) (string, []interface{})
isEmpty gets whether the specified object is considered empty or not.
Types ¶
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB
func (*DB) DeleteContext ¶
func (*DB) DeleteDynamic ¶ added in v0.1.17
Delete 刪除数据
func (*DB) InsertContext ¶
func (*DB) InsertDynamic ¶ added in v0.1.17
func (g *DB) InsertDynamic(stmt, sql string, param interface{}) (lastInsertId int64, affected int64, err error)
Insert 插入数据
func (*DB) QueryRaw ¶ added in v0.1.15
func (g *DB) QueryRaw(sql string, params map[string]interface{}, resultType ResultType) func(res interface{}) error
func (*DB) Select ¶
func (g *DB) Select(stmt string, param interface{}, rowBound ...*rowBounds) func(res interface{}) (int64, error)
reference from https://github.com/yinshuwei/osm/blob/master/osm.go end
func (*DB) SelectContext ¶
func (*DB) SelectDynamic ¶ added in v0.1.25
func (g *DB) SelectDynamic(stmt, sql string, param interface{}, resultType ResultType, rowBound ...*rowBounds) func(res interface{}) (int64, error)
Select 分页查询查询数据
func (*DB) SelectPage ¶
func (g *DB) SelectPage(stmt string, param interface{}, pageRows, offset int64) func(res interface{}, num interface{}) error
SelectPage 历史原因 暂时保留
func (*DB) TransactionTX ¶
Transaction tx
func (*DB) UpdateContext ¶
func (*DB) UpdateDynamic ¶ added in v0.1.17
Update 更新数据
type DBConfig ¶
type DBConfig struct { DB []*DataSource `yaml:"db"` ShowSQL bool `yaml:"showSQL"` Mappers []string `yaml:"mappers"` // contains filtered or unexported fields }
type DBConfigBuilder ¶
type DBConfigBuilder struct {
// contains filtered or unexported fields
}
func NewDBConfigBuilder ¶
func NewDBConfigBuilder() *DBConfigBuilder
func (*DBConfigBuilder) Build ¶
func (d *DBConfigBuilder) Build() *DBConfig
func (*DBConfigBuilder) DB ¶
func (d *DBConfigBuilder) DB(db map[string]*GoBatisDB) *DBConfigBuilder
func (*DBConfigBuilder) DS ¶
func (d *DBConfigBuilder) DS(dss []*DataSource) *DBConfigBuilder
func (*DBConfigBuilder) Mappers ¶
func (d *DBConfigBuilder) Mappers(mappers []string) *DBConfigBuilder
func (*DBConfigBuilder) ShowSQL ¶
func (d *DBConfigBuilder) ShowSQL(showSQL bool) *DBConfigBuilder
type DBOption ¶
type DBOption struct {
// contains filtered or unexported fields
}
func NewDBOption ¶
func NewDBOption() *DBOption
func NewDBOption_ ¶
func (*DBOption) Type ¶
func (ds *DBOption) Type() OptionType
type DSOption ¶
type DSOption struct {
// contains filtered or unexported fields
}
func NewDSOption ¶
func NewDSOption() *DSOption
func NewDSOption_ ¶
func NewDSOption_(dss []*DataSource, showSQL bool, mappers []string) *DSOption
func (*DSOption) DS ¶
func (ds *DSOption) DS(dss []*DataSource) *DSOption
func (*DSOption) Type ¶
func (ds *DSOption) Type() OptionType
type DataSource ¶
type DataSource struct { DataSource string `yaml:"datasource"` DriverName string `yaml:"driverName"` DataSourceName string `yaml:"dataSourceName"` MaxLifeTime int `yaml:"maxLifeTime"` MaxOpenConns int `yaml:"maxOpenConns"` MaxIdleConns int `yaml:"maxIdleConns"` }
func NewDataSource ¶
func NewDataSource(dataSource string, driverName string, dataSourceName string) *DataSource
NewDataSource new data source
func NewDataSource_ ¶
func NewDataSource_(dataSource string, driverName string, dataSourceName string, maxLifeTime int, maxOpenConns int, maxIdleConns int) *DataSource
NewDataSource_ new data source
type DataSourceBuilder ¶
type DataSourceBuilder struct {
// contains filtered or unexported fields
}
func NewDataSourceBuilder ¶
func NewDataSourceBuilder() *DataSourceBuilder
func (*DataSourceBuilder) Build ¶
func (d *DataSourceBuilder) Build() *DataSource
func (*DataSourceBuilder) DataSource ¶
func (d *DataSourceBuilder) DataSource(ds string) *DataSourceBuilder
DataSource
func (*DataSourceBuilder) DataSourceName ¶
func (d *DataSourceBuilder) DataSourceName(dsn string) *DataSourceBuilder
DataSourceName
func (*DataSourceBuilder) DriverName ¶
func (d *DataSourceBuilder) DriverName(dn string) *DataSourceBuilder
DriverName
func (*DataSourceBuilder) MaxIdleConns ¶
func (d *DataSourceBuilder) MaxIdleConns(mic int) *DataSourceBuilder
MaxIdleConns
func (*DataSourceBuilder) MaxLifeTime ¶
func (d *DataSourceBuilder) MaxLifeTime(mlt int) *DataSourceBuilder
MaxLifeTime
func (*DataSourceBuilder) MaxOpenConns ¶
func (d *DataSourceBuilder) MaxOpenConns(moc int) *DataSourceBuilder
MaxOpenConns
type FileOption ¶
type FileOption struct {
// contains filtered or unexported fields
}
func NewFileOption ¶
func NewFileOption(pt ...string) *FileOption
NewFileOption db config file path, default: db.yml
func (*FileOption) ToDBConf ¶
func (f *FileOption) ToDBConf() *DBConfig
func (*FileOption) Type ¶
func (f *FileOption) Type() OptionType
type GoBatis ¶
type GoBatis interface { // Select 查询数据 Select(stmt string, param interface{}, rowBound ...*rowBounds) func(res interface{}) (int64, error) // SelectContext 查询数据with context SelectContext(ctx context.Context, stmt string, param interface{}, rowBound ...*rowBounds) func(res interface{}) (int64, error) // Insert 插入数据 Insert(stmt string, param interface{}) (lastInsertId int64, affected int64, err error) // InsertContext 插入数据with context InsertContext(ctx context.Context, stmt string, param interface{}) (lastInsertId int64, affected int64, err error) // Update 更新数据 Update(stmt string, param interface{}) (affected int64, err error) // UpdateContext 更新数据with context UpdateContext(ctx context.Context, stmt string, param interface{}) (affected int64, err error) // Delete 刪除数据 Delete(stmt string, param interface{}) (affected int64, err error) // DeleteContext 刪除数据with context DeleteContext(ctx context.Context, stmt string, param interface{}) (affected int64, err error) // Select 分页查询查询数据 SelectPage(stmt string, param interface{}, pageRows, offset int64) func(res interface{}, num interface{}) error // QueryRaw 原始sql查询 只支持变量替换,不支持条件 QueryRaw(sql string, params map[string]interface{}, resultType ResultType) func(res interface{}) error //ExecRaw 原始sql执行 只支持变量替换,不支持条件 ExecRaw(sql string, params map[string]interface{}) (int64, error) // 动态Insert 插入数据 支持xml里面的条件语法 InsertDynamic(stmt, sql string, param interface{}) (lastInsertId int64, affected int64, err error) // 动态Update 更新数据 支持xml里面的条件语法 UpdateDynamic(stmt, sql string, param interface{}) (affected int64, err error) // 动态Delete 刪除数据 支持xml里面的条件语法 DeleteDynamic(stmt, sql string, param interface{}) (affected int64, err error) // 动态Select 分页查询查询数据 支持xml里面的条件语法 SelectDynamic(stmt, sql string, param interface{}, resultType ResultType, rowBound ...*rowBounds) func(res interface{}) (int64, error) }
type ILogger ¶
type ILogger interface { SetLevel(level LogLevel) Info(format string, v ...interface{}) Debug(format string, v ...interface{}) Warn(format string, v ...interface{}) Error(format string, v ...interface{}) Fatal(format string, v ...interface{}) }
如果想定制logger可以实现此接口,否则日志将使用默认打印
var LOG ILogger = defLog
type IOption ¶
type IOption interface { Type() OptionType ToDBConf() *DBConfig }
type NullFloat64 ¶
type NullFloat64 = sql.NullFloat64
type NullString ¶
type NullString = sql.NullString
type OptionType ¶
type OptionType int
const ( OptionTypeFile OptionType = 1 OptionTypeDS OptionType = 2 OptionTypeDB OptionType = 3 )
type ResultType ¶
type ResultType string
type TX ¶
type TX struct {
// contains filtered or unexported fields
}
TX
func (*TX) DeleteContext ¶
func (*TX) DeleteDynamic ¶ added in v0.1.17
Delete 刪除数据
func (*TX) InsertContext ¶
func (*TX) InsertDynamic ¶ added in v0.1.17
func (g *TX) InsertDynamic(stmt, sql string, param interface{}) (lastInsertId int64, affected int64, err error)
Insert 插入数据
func (*TX) QueryRaw ¶ added in v0.1.15
func (g *TX) QueryRaw(sql string, params map[string]interface{}, resultType ResultType) func(res interface{}) error
func (*TX) Select ¶
func (g *TX) Select(stmt string, param interface{}, rowBound ...*rowBounds) func(res interface{}) (int64, error)
reference from https://github.com/yinshuwei/osm/blob/master/osm.go end
func (*TX) SelectContext ¶
func (*TX) SelectDynamic ¶ added in v0.1.25
func (g *TX) SelectDynamic(stmt, sql string, param interface{}, resultType ResultType, rowBound ...*rowBounds) func(res interface{}) (int64, error)
Select 分页查询查询数据
func (*TX) SelectPage ¶
func (g *TX) SelectPage(stmt string, param interface{}, pageRows, offset int64) func(res interface{}, num interface{}) error
SelectPage 历史原因 暂时保留
func (*TX) UpdateContext ¶
func (*TX) UpdateDynamic ¶ added in v0.1.17
Update 更新数据
Source Files
¶
- coll_stack.go
- config.go
- config_builder.go
- config_db.go
- config_mapper.go
- dbstruct.go
- executor.go
- expr.go
- gobatis.go
- gobatis_db.go
- logger.go
- mapper.go
- nilable_structs.go
- option.go
- option_db.go
- option_ds.go
- option_file.go
- parser_xml.go
- proc_params.go
- proc_res.go
- sql_source.go
- util.go
- util_builder.go
- val.go
- xmltag.go