mirror of
https://github.com/muety/wakapi.git
synced 2023-08-10 21:12:56 +03:00
refactor: migrate to latest gorm version
refactor: language mappings implementation
This commit is contained in:
@ -2,8 +2,6 @@ package utils
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/muety/wakapi/config"
|
||||
"regexp"
|
||||
"time"
|
||||
)
|
||||
@ -28,41 +26,3 @@ func ParseUserAgent(ua string) (string, string, error) {
|
||||
}
|
||||
return groups[0][1], groups[0][2], nil
|
||||
}
|
||||
|
||||
func MakeConnectionString(config *config.Config) string {
|
||||
switch config.Db.Dialect {
|
||||
case "mysql":
|
||||
return mysqlConnectionString(config)
|
||||
case "postgres":
|
||||
return postgresConnectionString(config)
|
||||
case "sqlite3":
|
||||
return sqliteConnectionString(config)
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func mysqlConnectionString(config *config.Config) string {
|
||||
//location, _ := time.LoadLocation("Local")
|
||||
return fmt.Sprintf("%s:%s@tcp(%s:%d)/%s?charset=utf8&parseTime=true&loc=%s&sql_mode=ANSI_QUOTES",
|
||||
config.Db.User,
|
||||
config.Db.Password,
|
||||
config.Db.Host,
|
||||
config.Db.Port,
|
||||
config.Db.Name,
|
||||
"Local",
|
||||
)
|
||||
}
|
||||
|
||||
func postgresConnectionString(config *config.Config) string {
|
||||
return fmt.Sprintf("host=%s port=%d user=%s dbname=%s password=%s sslmode=disable",
|
||||
config.Db.Host,
|
||||
config.Db.Port,
|
||||
config.Db.User,
|
||||
config.Db.Name,
|
||||
config.Db.Password,
|
||||
)
|
||||
}
|
||||
|
||||
func sqliteConnectionString(config *config.Config) string {
|
||||
return config.Db.Name
|
||||
}
|
||||
|
Reference in New Issue
Block a user