I have project that use golang-revel and in my project, i need to connect to 2 databases. Currently, i can migrate the database one by one, but if this project is getting bigger i need to be able to migrate all databases. Is there any way that i can get the database name dynamically in the app.conf ?
# Settings for database used in GORM Framework
db.automigrate = false
db.driver = mysql
db.username = root
db.password =
db.dbname = root_database
db.dbname.otherdatabase = other_database_name
db.companies = other_companies
db.charset = utf8
db.parseTime = True
db.loc =
db.log = true
i can migrate by getting db.dbname with Dbname = r.Config.StringDefault("db.dbname", "")
But how can i get db.dbname.otherdatabase or more database dynamically, so that it can grab all database in the future ?
You need to store all the names in one variable with separator, for simplicity, just use comma
Then use
Splitfunction by,see here for
r.Config.StringDefaultfunction