February 2018
Intermediate to advanced
340 pages
9h 43m
English
The standard lib package, database/sql, provides the Open function to initialize the connection to the database with the driver name and connection details (connection URL in this case). Note that the Open function does not create the connection immediately, and may only validate the parameters passed to the function.
The connection to the database could be verified by the Ping method, which is available in the returned DB struct pointer.
The driver itself is initialized in the init function of the driver package. The driver registers itself with the driver name by the Register function of the sql package. The github.com/lib/pq driver registers itself as postgres.
Read now
Unlock full access