(n int, ret *ast.ReturnStmt)
| 953 | } |
| 954 | |
| 955 | func (t *walker) wrapReturnCall(n int, ret *ast.ReturnStmt) { |
| 956 | // Common validation |
| 957 | switch { |
| 958 | case len(t.errorIndices) != 1: |
| 959 | t.logf(ret.Pos(), "skipping function with multiple error returns") |
| 960 | return |
| 961 | case t.errorIndices[0] != t.numReturns-1: |
| 962 | t.logf(ret.Pos(), "skipping function with non-final error return") |
| 963 | return |
| 964 | case t.isErrtraceWrap(ret.Results[0]): |
| 965 | return |
| 966 | case t.optout(ret.Pos()): |
| 967 | return |
| 968 | } |
| 969 | |
| 970 | if t.opts.NoWrapN { |
| 971 | *t.inserts = append(*t.inserts, |
| 972 | &insertReturnNBlockStart{N: n, Before: ret.Pos(), SkipReturn: ret.Results[0].Pos()}, |
| 973 | &insertReturnNBlockClose{N: n, After: ret.End()}, |
| 974 | ) |
| 975 | return |
| 976 | } |
| 977 | |
| 978 | if n > 6 { |
| 979 | t.logf(ret.Pos(), "skipping function with too many return values") |
| 980 | return |
| 981 | } |
| 982 | |
| 983 | t.wrapExpr(n, ret.Results[0]) |
| 984 | } |
| 985 | |
| 986 | func (t *walker) wrapExpr(n int, expr ast.Expr) { |
| 987 | switch { |
no test coverage detected