func GetDB() *gorm.DB {
	return DB
}
GetDB helps you to get a connection
package database
import (
	"errors"
	"fmt"
	"io"
	"log"
	"os"
	"time"
	"github.com/spf13/viper"
	"github.com/yakuter/ugin/model"
	"gorm.io/driver/mysql"
	"gorm.io/driver/postgres"
	"gorm.io/driver/sqlite"
	"gorm.io/gorm"
	"gorm.io/gorm/logger"
)
var (
	DB    *gorm.DB
	err   error
	DBErr error
)
type Database struct {
	*gorm.DB
}
func Setup() error {
	var db = DB
	driver := viper.GetString("database.driver")
	dbname := viper.GetString("database.dbname")
	username := viper.GetString("database.username")
	password := viper.GetString("database.password")
	host := viper.GetString("database.host")
	port := viper.GetString("database.port")
	logmode := viper.GetBool("database.logmode")
	sslmode := viper.GetString("database.sslmode")
	loglevel := logger.Silent
	if logmode {
		loglevel = logger.Info
	}
	newDBLogger := logger.New(
		log.New(getWriter(), "\r\n", log.LstdFlags),  
		logger.Config{
			SlowThreshold:             time.Second,  
			LogLevel:                  loglevel,     
			IgnoreRecordNotFoundError: true,         
			Colorful:                  false,        
		},
	)
	switch driver {
	case "sqlite":
		db, err = gorm.Open(sqlite.Open("ugin.db"), &gorm.Config{Logger: newDBLogger})
	case "mysql":
		dsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8&parseTime=True", username, password, host, port, dbname)
		db, err = gorm.Open(mysql.Open(dsn), &gorm.Config{Logger: newDBLogger})
	case "postgres":
		dsn := fmt.Sprintf(
			"host=%s user=%s password=%s dbname=%s port=%s sslmode=%s",
			host, username, password, dbname, port, sslmode,
		)
		db, err = gorm.Open(postgres.Open(dsn), &gorm.Config{Logger: newDBLogger})
	default:
		return errors.New("Unsupported database driver")
	}
	if err != nil {
		DBErr = err
		return err
	}
	db.AutoMigrate(&model.Post{}, &model.Tag{})
	DB = db
	return nil
}