Here I was wrong. The error is returned by the Scan(...)-call (which I didn't catch, these are my first steps with go ...)
The reason why I was fixated on the Query-call was the way I tracked the cause:
I printed the functioning and not functioning DB-connection and saw that they differ
&{0 {:memory: 0xc00000e0e0} 0 {0 0} [0xc000126a20] ...
&{0 {:memory: 0xc00000e0e0} 0 {0 0} [] ...
at the slice. Pinging the non-functioning DB-connection put a new addres into the empty slice, so I assumed that this slice holds the open connections.
Then I narroed the two lines until I found the line where the switch to the empty slice happand which was oddly the Query-call.
The Questions which remain are, dose this connection gets closed allways when an error appears? Is it a bug?
Can I use the API to figure if this connection was closed? Ping doesn't work because it just creates a new connection and pretends everything is fine.
My settings are:
.SetMaxOpenConns(1)
.SetConnMaxLifetime(0)
.SetConnMaxIdleTime(0)
(because I really don't want this connection to close ;)
Thanks Stephan