mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-09 13:28:01 -05:00
* Implement static analysis to prevent panics * Add nopanic to nogo * Fix violations and add exclusions Fix violations and add exclusions for all * Changelog fragment * Use pass.Report instead of pass.Reportf * Remove strings.ToLower for checking init method name * Add exclusion for herumi init * Move api/client/beacon template function to init and its own file * Fix nopanic testcase
27 lines
649 B
Go
27 lines
649 B
Go
package testdata
|
|
|
|
func A() error {
|
|
panic("feeling cute, let's panic!") // want "panic\\(\\) should not be used, except in rare situations or init functions"
|
|
}
|
|
|
|
func B(foo interface{}) error {
|
|
if foo == nil {
|
|
panic("impossible condition: foo is nil") //lint:nopanic -- This is validated by the caller.
|
|
}
|
|
|
|
if _, ok := foo.(string); !ok {
|
|
panic("foo should not be a string!!") // want "panic\\(\\) should not be used, except in rare situations or init functions"
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
//lint:nopanic -- This is method is really safe ;)
|
|
func C(foo interface{}) error {
|
|
if foo == nil {
|
|
panic("impossible condition: foo is nil")
|
|
}
|
|
|
|
return nil
|
|
}
|