Golang lint rule to require launching a goroutine with a recover

200 Views Asked by At

I want to create a go lint rule that requires all goroutines to be launched with a wrapper function that can recover from a crash on the goroutine (this will also take an onRecover callback that will cancel context of request). The pain point I am trying to solve is that a crash on any goroutine will crash the entire server - I want to protect against this.

I currently use https://golangci-lint.run/usage/linters/ for most of my linters.

Two examples of Go routine wrappers that will protect against a crash in the goroutine:

Also please feel free to call out why I should not do this. Seems like an obvious idea and given that this lint rule does not exist I wouldn't be surprised if I am missing something.

0

There are 0 best solutions below