(fullPath, dbName string)
| 33 | } |
| 34 | |
| 35 | func LoadDBConnByPathWithErr(fullPath, dbName string) (*gorm.DB, error) { |
| 36 | if _, err := createDirWhenNotExist(true, path.Dir(fullPath)); err != nil { |
| 37 | return nil, fmt.Errorf("init db dir failed, err: %v", err) |
| 38 | } |
| 39 | if _, err := os.Stat(fullPath); err != nil { |
| 40 | f, err := os.Create(fullPath) |
| 41 | if err != nil { |
| 42 | return nil, fmt.Errorf("init %s db file failed, err: %v", dbName, err) |
| 43 | } |
| 44 | _ = f.Close() |
| 45 | } |
| 46 | |
| 47 | db, err := GetDBWithPath(fullPath) |
| 48 | if err != nil { |
| 49 | return nil, fmt.Errorf("init %s db failed, err: %v", dbName, err) |
| 50 | } |
| 51 | return db, nil |
| 52 | } |
| 53 | |
| 54 | func CloseDB(db *gorm.DB) { |
| 55 | sqlDB, err := db.DB() |
nothing calls this directly
no test coverage detected