V
V
Vladimir Grabko2016-06-03 23:10:41
go
Vladimir Grabko, 2016-06-03 23:10:41

How to properly declare a connection to the database?

I now have a global variable to work with the database. But judging by the answers on the toaster, doing it this way is bad (and how to do it right was not answered here). I can’t even imagine how to do it right (it doesn’t connect in every routine)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ilya, 2016-06-03
@VGrabko

I make a package for working with the database, I declare the exported connection there, write all the presets in the functions, run the necessary functions with a panic in the init of the package, and assign the connection to the exported variable in the last line.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question