option初始化需要赋予部分默认值
This commit is contained in:
@@ -38,18 +38,27 @@ func SetMysql(user, password, host, database string, port int) Option {
|
||||
Database: database,
|
||||
Password: password,
|
||||
}
|
||||
if o.Mysql.Port == 0 {
|
||||
o.Mysql.Port = 3306
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 使用sqlite数据库
|
||||
func SetSqlite(dbPath string) Option {
|
||||
return func(o *clientOptions) {
|
||||
o.Db = "sqlite"
|
||||
o.Sqlite = &SqliteOptions{
|
||||
DbPath: dbPath,
|
||||
}
|
||||
if o.Sqlite.DbPath == "" {
|
||||
o.Sqlite.DbPath = "sqlite.db"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 表名前缀
|
||||
func SetTablePrefix(perfix string) Option {
|
||||
return func(o *clientOptions) {
|
||||
o.Prefix = perfix
|
||||
|
||||
Reference in New Issue
Block a user