Your `var db=initDB()` runs before init(), and it returns an error, so the program aborts.
Here's a change which initializes db explicitly in the init function, and it works as you expect: https://play.golang.org/p/xsUU2hfnx-w The init function is called after all variable initializations happen, look here: https://golang.org/doc/effective_go.html#initialization On Tue, Jan 12, 2021 at 9:27 AM Martin Ziebiker <ziebi...@itassistance.cz> wrote: > Hello, please does anyone know why init() won't run? > > Thank You very much! > > https://play.golang.org/p/0PDUJlF8X1w > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/golang-nuts/5809011a-ceaf-45ff-993b-59641dfabd7fn%40googlegroups.com > <https://groups.google.com/d/msgid/golang-nuts/5809011a-ceaf-45ff-993b-59641dfabd7fn%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CA%2Bv29LusGU-pwB727AjYbZoi9%2BXL_NWB5ndx-OPbVUDPa718Cw%40mail.gmail.com.