There is a race condition here, all the goroutines started using function f reference directly the err variable. When more than one change it at the same or close times, you get:
goroutine 176881 [running]:
github.com/iamseth/oracledb_exporter/collector.(Exporter).scrape.func2()
.../oracledb_exporter/collector/collector.go:316 +0x13e9
created by github.com/iamseth/oracledb_exporter/collector.(Exporter).scrape in goroutine 176838
.../oracledb_exporter/collector/collector.go:322 +0x776
https://github.com/iamseth/oracledb_exporter/blame/29c8869cf60dc5b318236000f09fb69e92846620/collector/collector.go#L316
There is a race condition here, all the goroutines started using function f reference directly the err variable. When more than one change it at the same or close times, you get:
panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x9f2229]
goroutine 176881 [running]: github.com/iamseth/oracledb_exporter/collector.(Exporter).scrape.func2() .../oracledb_exporter/collector/collector.go:316 +0x13e9 created by github.com/iamseth/oracledb_exporter/collector.(Exporter).scrape in goroutine 176838 .../oracledb_exporter/collector/collector.go:322 +0x776