Skip to content

Instantly share code, notes, and snippets.

@bastianccm
Created February 26, 2020 13:08
Show Gist options
  • Save bastianccm/23c8865a23ff40a66ce027876a2da343 to your computer and use it in GitHub Desktop.
Save bastianccm/23c8865a23ff40a66ce027876a2da343 to your computer and use it in GitHub Desktop.
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