3 ms·
I'm not familiar with how the DB classes work (and I guess what counts as a function "ending"). Since `db.Close()` is deferred, is there a mysql connection open
by fideloper 10y ago
I'm not familiar with how the DB classes work (and I guess what counts as a function "ending"). Since `db.Close()` is deferred, is there a mysql connection open for as long as the web server is open in this case?
The main() function doesn't "end" until the web listener is stopped, correct?
- stygiansonic 10y agoYes, that's correct. `http.ListenAndServe()` doesn't return until the web listener is stopped. This is actually the intended usage of `sql.Open()`: https://golang.org/pkg/database/sql/#Open https://golang.org/pkg/database/sql/#Open (it maintains its own connection pool and is safe for concurrent use)