Open Dragomir-Ivanov opened 4 years ago
Can confirm the issue. Had these locally, too. Seems like some concurrency problem.
Hmm, I think there are no goroutines involved, but map iteration is non-deterministic, so If any piece of code relies on map iteration order, it can bomb like that.
The issue is that ReadConfig
uses the global flag.CommandLine
var and adds the flags each time called. This leads to the panic. See: https://github.com/tarent/loginsrv/blob/master/login/config.go#L202
@g-w But when I run go test -p 1
it still panics, although it should execute only one test at a time.
@Dragomir-Ivanov The issue is not related to parallelism. The issue is that if you read the config twice, all flags are added twice and newer versions of the flag package prevent this. This trigger the panic you've observed. I added a pr with a workaround for the issue.
@g-w Thanks! Apparently it panics only on test count > 1, so your patch fixes that.