Skip to content

Commit

Permalink
create database config
Browse files Browse the repository at this point in the history
  • Loading branch information
pacholoamit committed Jun 24, 2022
1 parent 0ddea41 commit 0020dd5
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion pkg/config/app.go
Original file line number Diff line number Diff line change
@@ -1 +1,23 @@
package config
package config

import (
"gorm.io/driver/sqlite"
"gorm.io/gorm"
)

var (
db *gorm.DB
)

func Connect() {
d, err := gorm.Open(sqlite.Open("GO-TASK-MGR.db"), &gorm.Config{})
if err != nil {
panic("failed to connect to database")
}

db = d
}

func GetDB() *gorm.DB {
return db
}

0 comments on commit 0020dd5

Please sign in to comment.