mirror of https://github.com/1Panel-dev/1Panel
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
566 B
26 lines
566 B
package configs
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
)
|
|
|
|
type Sqlite struct {
|
|
Path string `mapstructure:"path"`
|
|
DbFile string `mapstructure:"db_file"`
|
|
}
|
|
|
|
func (s *Sqlite) Dsn() string {
|
|
if _, err := os.Stat(s.Path); err != nil {
|
|
if err := os.MkdirAll(s.Path, os.ModePerm); err != nil {
|
|
panic(fmt.Errorf("init db dir falied, err: %v", err))
|
|
}
|
|
}
|
|
if _, err := os.Stat(s.Path + "/" + s.DbFile); err != nil {
|
|
if _, err := os.Create(s.Path + "/" + s.DbFile); err != nil {
|
|
panic(fmt.Errorf("init db file falied, err: %v", err))
|
|
}
|
|
}
|
|
return s.Path + "/" + s.DbFile
|
|
}
|