This is a creation in Article, where the information may have evolved or changed.
Sql. Open does not create a connection, it creates only one db instance, and it creates a go to manage a connection pool for that DB instance (it is a long connection, but it is not created at open). The call to begin () takes a connection, rolls back, or returns when it is submitted. If EXEC () executes directly when you use it, a connection is taken out of the connection pool each time, and returned when exec finishes execution. The size of the connection pool can be adjusted by parameters.
The Golang SQL package has been processed concurrently and has maintained a pool of connections through channel, so there is no need to lock-share in go.
about each SQL. Open, I think it should be an inappropriate approach, which will lead to the connection is not reused, and generate too much short time to close the connection, to the database caused unnecessary pressure.