MCPcopy Create free account
hub / github.com/FloatTech/ZeroBot-Plugin-Playground / initialize

Function initialize

plugin/fgopickup/dbengine.go:20–38  ·  view source on GitHub ↗
(dbpath string)

Source from the content-addressed store, hash-verified

18}
19
20func initialize(dbpath string) *gorm.DB {
21 var err error
22 if _, err = os.Stat(dbpath); err != nil || os.IsNotExist(err) {
23 f, err := os.Create(dbpath)
24 if err != nil {
25 return nil
26 }
27 defer f.Close()
28 }
29 gdb, err := gorm.Open(sqlite.Open(dbpath))
30 if err != nil {
31 panic(err)
32 }
33 _ = gdb.AutoMigrate(&pickup{}, &pickupServant{}, &servant{})
34 orm := new(orm)
35 orm.DB = gdb
36 _dbEngine = orm
37 return gdb
38}

Callers 1

initFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected