1234567891011121314151617181920212223 |
- package utils
- import (
- "gorm.io/driver/sqlite"
- "gorm.io/gorm"
- "gorm.io/gorm/logger"
- )
- func InitDB() (db *gorm.DB) {
- var err error
- db, err = gorm.Open(sqlite.Open("/tmp/my.db"), &gorm.Config{})
- if err != nil {
- panic(err)
- }
- db.Logger.LogMode(logger.Info)
- return
- }
- type Page struct {
- ID int
- Name string
- }
|