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

Function initialize

plugin/qqci/model.go:37–56  ·  view source on GitHub ↗
(dbpath string)

Source from the content-addressed store, hash-verified

35}
36
37func initialize(dbpath string) *appdb {
38 var err error
39 if _, err = os.Stat(dbpath); err != nil || os.IsNotExist(err) {
40 // 生成文件
41 f, err := os.Create(dbpath)
42 if err != nil {
43 return nil
44 }
45 defer f.Close()
46 }
47 adb, err := gorm.Open(sqlite.Open(dbpath), &gorm.Config{})
48 if err != nil {
49 panic(err)
50 }
51 err = adb.AutoMigrate(&application{})
52 if err != nil {
53 panic(err)
54 }
55 return (*appdb)(adb)
56}
57
58func (adb *appdb) insert(app *application) error {
59 db := (*gorm.DB)(adb)

Callers 1

initFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected