Add and fix goconst

This commit is contained in:
Kristoffer Dalby 2021-11-14 18:06:25 +01:00
parent c9c16c7fb8
commit 9390348a65
No known key found for this signature in database
GPG key ID: 09F62DC067465735
3 changed files with 7 additions and 6 deletions

6
db.go
View file

@ -24,7 +24,7 @@ func (h *Headscale) initDB() error {
}
h.db = db
if h.dbType == "postgres" {
if h.dbType == POSTGRESQL {
db.Exec("create extension if not exists \"uuid-ossp\";")
}
err = db.AutoMigrate(&Machine{})
@ -66,12 +66,12 @@ func (h *Headscale) openDB() (*gorm.DB, error) {
}
switch h.dbType {
case "sqlite3":
case SQLITE:
db, err = gorm.Open(sqlite.Open(h.dbString), &gorm.Config{
DisableForeignKeyConstraintWhenMigrating: true,
Logger: log,
})
case "postgres":
case POSTGRESQL:
db, err = gorm.Open(postgres.Open(h.dbString), &gorm.Config{
DisableForeignKeyConstraintWhenMigrating: true,
Logger: log,