MCPcopy
hub / github.com/FloatTech/ZeroBot-Plugin / initialize

Function initialize

plugin/hitokoto/model.go:16–31  ·  view source on GitHub ↗

initialize 初始化

(dbpath string)

Source from the content-addressed store, hash-verified

14
15// initialize 初始化
16func initialize(dbpath string) (db *hitokotodb, err error) {
17 if _, err = os.Stat(dbpath); err != nil || os.IsNotExist(err) {
18 // 生成文件
19 f, err := os.Create(dbpath)
20 if err != nil {
21 return nil, err
22 }
23 _ = f.Close()
24 }
25 gdb, err := gorm.Open("sqlite3", dbpath)
26 if err != nil {
27 return
28 }
29 gdb.AutoMigrate(&hitokoto{})
30 return (*hitokotodb)(gdb), nil
31}
32
33type hitokoto struct {
34 ID int `json:"id" gorm:"column:id;primary_key"`

Callers 1

initFunction · 0.70

Calls 1

CloseMethod · 0.45

Tested by

no test coverage detected