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

Function initialize

plugin/score/model.go:44–62  ·  view source on GitHub ↗

initialize 初始化ScoreDB数据库

(dbpath string)

Source from the content-addressed store, hash-verified

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

Callers 1

initFunction · 0.70

Calls 1

CloseMethod · 0.45

Tested by

no test coverage detected