package dao import ( "context" "{{.ModPrefix}}{{.Name}}/internal/model" "github.com/bilibili/kratos/pkg/conf/paladin" "github.com/bilibili/kratos/pkg/database/sql" ) func NewDB() (db *sql.DB, cf func(), err error) { var ( cfg sql.Config ct paladin.TOML ) if err = paladin.Get("db.toml").Unmarshal(&ct); err != nil { return } if err = ct.Get("Client").UnmarshalTOML(&cfg); err != nil { return } db = sql.NewMySQL(&cfg) cf = func() {db.Close()} return } func (d *dao) RawArticle(ctx context.Context, id int64) (art *model.Article, err error) { // get data from db return }