MCPcopy Index your code
hub / github.com/FloatTech/ZeroBot-Plugin / initialize

Function initialize

plugin/chatcount/model.go:43–61  ·  view source on GitHub ↗

initialize 初始化

(dbpath string)

Source from the content-addressed store, hash-verified

41
42// initialize 初始化
43func initialize(dbpath string) *chattimedb {
44 var err error
45 if _, err = os.Stat(dbpath); err != nil || os.IsNotExist(err) {
46 // 生成文件
47 f, err := os.Create(dbpath)
48 if err != nil {
49 return nil
50 }
51 defer f.Close()
52 }
53 gdb, err := gorm.Open("sqlite3", dbpath)
54 if err != nil {
55 panic(err)
56 }
57 gdb.AutoMigrate(&chatTime{})
58 return &chattimedb{
59 db: gdb,
60 }
61}
62
63// Close 关闭
64func (ctdb *chattimedb) Close() error {

Callers 1

initFunction · 0.70

Calls 1

CloseMethod · 0.45

Tested by

no test coverage detected