In Go database/sql package it says it is rare to close the database with db.Close because it is meant to be shared by many go routines. Then which one is better when we are given 100 functions that queries from a same data:
- Open the database inside each function
- Open the database only one time and use the same connection for every 100 function.
1 is easier because if one fails other 99 can still be working. And no need to pass database connection arguments. But in performance wise which one is better?