Answer the question
In order to leave comments, you need to log in
How to connect to the database correctly?
Hello. I can not figure out how to connect to the database 1 time and then pass the connection identifier to the function.
Here is the connection
db, err := gorm.Open("mysql", "root:[email protected]/generais?charset=utf8&parseTime=True&loc=Local")
if err != nil {
log.Fatal(err)
}
db.DB()
db.DB().Ping()
db.DB().SetMaxIdleConns(10)
db.DB().SetMaxOpenConns(100)
db.SingularTable(true)
Answer the question
In order to leave comments, you need to log in
An elementary example if possible.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question