github.com/jxgolibs/go-oauth2-server@v1.0.1/cmd/util.go (about)

     1  package cmd
     2  
     3  import (
     4  	"github.com/RichardKnop/go-oauth2-server/config"
     5  	"github.com/RichardKnop/go-oauth2-server/database"
     6  	"github.com/jinzhu/gorm"
     7  )
     8  
     9  // initConfigDB loads the configuration and connects to the database
    10  func initConfigDB(mustLoadOnce, keepReloading bool, configBackend string) (*config.Config, *gorm.DB, error) {
    11  	// Config
    12  	cnf := config.NewConfig(mustLoadOnce, keepReloading, configBackend)
    13  
    14  	// Database
    15  	db, err := database.NewDatabase(cnf)
    16  	if err != nil {
    17  		return nil, nil, err
    18  	}
    19  
    20  	return cnf, db, nil
    21  }