Skip to content

Commit

Permalink
fix: use constant to fix linter
Browse files Browse the repository at this point in the history
  • Loading branch information
pclauberg committed Aug 22, 2024
1 parent 01b087d commit 1ab6e7a
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions database/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ const (
DialectMysql = "mysql"
// DialectPostgres is the postgres dialect.
DialectPostgres = "postgres"
// UnknownDialect is unknown.
UnknownDialect = "Unknown database dialect: "
)

// Config holds all configuration values for the DB setup
Expand Down Expand Up @@ -43,7 +45,7 @@ func (c *Config) Driver() gorm.Dialector {
c.Host, c.Port, c.User, c.Password, dbName, c.SSLMode)
return postgres.Open(dsn)
default:
panic("Unknown database dialect: " + c.Dialect)
panic(UnknownDialect + c.Dialect)
}
}

Expand All @@ -57,7 +59,7 @@ func (c *Config) MigrationURL() string {
return fmt.Sprintf("%s:%s@%s:%s/%s?sslmode=%s",
c.User, c.Password, c.Host, c.Port, c.Name, c.SSLMode)
default:
panic("Unknown database dialect: " + c.Dialect)
panic(UnknownDialect + c.Dialect)
}
}

Expand All @@ -70,6 +72,6 @@ func (c *Config) createDatabaseQuery() string {
case DialectPostgres:
return `CREATE DATABASE "%s" ENCODING=UTF8;`
default:
panic("Unknown database dialect: " + c.Dialect)
panic(UnknownDialect + c.Dialect)
}
}

0 comments on commit 1ab6e7a

Please sign in to comment.