I'm a beginner in Golang and I'm working on a small library which need to get a DB connection at some point in the code for différent sub package / method call. I'm just wondering how I can manage this ?

Example, If I manage to have a webserver, it works with handler, so how can I get this connection inside this function ? It could be used with another process, simple method call or MVC model ?

I don't want to use global because for me it's a bad practice except if it's very exceptional way (or tricky somehow).

I read a lot of write in different website, but still, I'm asking and learning from different opinion and experiences.

Thanks for your time !