Created
February 26, 2020 13:08
-
-
Save bastianccm/23c8865a23ff40a66ce027876a2da343 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package db | |
import ( | |
"flamingo.me/dingo" | |
"github.com/jinzhu/gorm" | |
_ "github.com/jinzhu/gorm/dialects/sqlite" | |
) | |
type Module struct{} | |
func (*Module) Configure(injector *dingo.Injector) { | |
injector.Bind(new(gorm.DB)).ToProvider(func() *gorm.DB { | |
db, err := gorm.Open("sqlite3", "test.db") | |
if err != nil { | |
panic(err) | |
} | |
return db | |
}).In(dingo.Singleton) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment