Open jayhuang75 opened 6 years ago
Hi @jayhuang75 , just happened to view this demo recently. In regards to your question, since the application is only creating one connection and does not deal with concurrent sessions (ie. session.copy()
), you need not worry about closing the session. The session is closed when the application is done running and there shouldn't be any performance impact. Here is an example from mongodb's website - notice how they only close their copy sessions. However, if you still want to (and you can) include defer session.close()
, it is recommended to be placed in the main()
function (see similar Stack overflow question).
Hello @mlabouardy its a really good demo, I'm still learning the Dao implementation in Golang. My question is when we close the session. is there any performance impact if we are not closing the session?
defer session.Close()