(fullPath, dbName string)
| 14 | ) |
| 15 | |
| 16 | func LoadDBConnByPath(fullPath, dbName string) *gorm.DB { |
| 17 | if _, err := createDirWhenNotExist(true, path.Dir(fullPath)); err != nil { |
| 18 | panic(fmt.Errorf("init db dir failed, err: %v", err)) |
| 19 | } |
| 20 | if _, err := os.Stat(fullPath); err != nil { |
| 21 | f, err := os.Create(fullPath) |
| 22 | if err != nil { |
| 23 | panic(fmt.Errorf("init %s db file failed, err: %v", dbName, err)) |
| 24 | } |
| 25 | _ = f.Close() |
| 26 | } |
| 27 | |
| 28 | db, err := GetDBWithPath(fullPath) |
| 29 | if err != nil { |
| 30 | panic(err) |
| 31 | } |
| 32 | return db |
| 33 | } |
| 34 | |
| 35 | func LoadDBConnByPathWithErr(fullPath, dbName string) (*gorm.DB, error) { |
| 36 | if _, err := createDirWhenNotExist(true, path.Dir(fullPath)); err != nil { |
nothing calls this directly
no test coverage detected