MCPcopy Create free account
hub / github.com/GoogleCloudPlatform/golang-samples / getDB

Function getDB

cloudsql/mysql/database-sql/cloudsql.go:42–47  ·  view source on GitHub ↗

getDB lazily instantiates a database connection pool. Users of Cloud Run or Cloud Functions may wish to skip this lazy instantiation and connect as soon as the function is loaded. This is primarily to help testing.

()

Source from the content-addressed store, hash-verified

40// Cloud Functions may wish to skip this lazy instantiation and connect as soon
41// as the function is loaded. This is primarily to help testing.
42func getDB() *sql.DB {
43 once.Do(func() {
44 db = mustConnect()
45 })
46 return db
47}
48
49// migrateDB creates the votes table if it does not already exist.
50func migrateDB(db *sql.DB) error {

Callers 1

VotesFunction · 0.70

Calls 2

DoMethod · 0.80
mustConnectFunction · 0.70

Tested by

no test coverage detected