We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
func createDatabase() (*gorm.DB, error) { dbType := config.GetString("db.type") dbAddr := config.GetString("db.addr") dbName := config.GetString("db.database") dbUser := config.GetString("db.user") dbPassword := config.GetString("db.password") dbCharset := config.GetString("db.charset") conn := "" switch dbType { case "mysql": conn = fmt.Sprintf("%s:%s@(%s)/%s?charset=%s&parseTime=True&loc=Local", dbUser, dbPassword, dbAddr, dbName, dbCharset) case "sqlite": conn = dbAddr case "mssql": return nil, errors.New("TODO:suport sqlServer") case "postgres": hostPort := strings.Split(dbAddr, ":") if len(hostPort) == 2 { return nil, errors.New("db.addr must be like this host:ip") } conn = fmt.Sprintf("host=%s port=%s user=%s dbname=%s password=%s sslmode=disable", hostPort[0], hostPort[1], dbUser, dbName, dbPassword) default: return nil, fmt.Errorf("database type %s is not supported by felix ginrbo", dbType) } return gorm.Open(dbType, conn) }
其中的
if len(hostPort) == 2 { return nil, errors.New("db.addr must be like this host:ip") }
应该是len(hostPort) != 2
len(hostPort) != 2
The text was updated successfully, but these errors were encountered:
No branches or pull requests
其中的
应该是
len(hostPort) != 2
The text was updated successfully, but these errors were encountered: