ops: add ops scripts
This commit is contained in:
@@ -27,14 +27,9 @@ var Analyzer = &analysis.Analyzer{
|
||||
}
|
||||
|
||||
func run(pass *analysis.Pass) (any, error) {
|
||||
result, ok := pass.ResultOf[inspect.Analyzer]
|
||||
insp, ok := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("inspect analyzer result is unavailable")
|
||||
}
|
||||
|
||||
insp, ok := result.(*inspector.Inspector)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("inspect analyzer returned %T, want *inspector.Inspector", result)
|
||||
panic("inspect.Analyzer did not produce *inspector.Inspector")
|
||||
}
|
||||
|
||||
insp.WithStack([]ast.Node{(*ast.IfStmt)(nil)}, func(n ast.Node, isPush bool, stack []ast.Node) bool {
|
||||
@@ -44,7 +39,7 @@ func run(pass *analysis.Pass) (any, error) {
|
||||
|
||||
stmt, ok := n.(*ast.IfStmt)
|
||||
if !ok {
|
||||
return true
|
||||
panic("inspector passed a non-IfStmt node to an IfStmt stack walk")
|
||||
}
|
||||
if stmt.Init == nil {
|
||||
return true
|
||||
|
||||
Reference in New Issue
Block a user