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

Function initDatabase

plugin/chess/db.go:42–56  ·  view source on GitHub ↗

initDatabase init database

(dbPath string)

Source from the content-addressed store, hash-verified

40
41// initDatabase init database
42func initDatabase(dbPath string) {
43 var err error
44 if _, err = os.Stat(dbPath); err != nil || os.IsNotExist(err) {
45 f, err := os.Create(dbPath)
46 if err != nil {
47 panic(err)
48 }
49 defer f.Close()
50 }
51 chessDB, err = gorm.Open("sqlite3", dbPath)
52 if err != nil {
53 panic(err)
54 }
55 chessDB.AutoMigrate(&elo{}, &pgn{})
56}
57
58// createELO 创建 ELO
59func (s *chessDBService) createELO(uin int64, name string, rate int) error {

Callers 1

initFunction · 0.85

Calls 1

CloseMethod · 0.45

Tested by

no test coverage detected