maybeFail checks a potential failure against a specific failure map.
(pos token.Pos, fmtStr string, args ...any)
| 81 | |
| 82 | // maybeFail checks a potential failure against a specific failure map. |
| 83 | func (pc *passContext) maybeFail(pos token.Pos, fmtStr string, args ...any) { |
| 84 | if fd, ok := pc.failures[pc.positionKey(pos)]; ok { |
| 85 | msg := fmt.Sprintf(fmtStr, args...) |
| 86 | index := slices.IndexFunc(fd.wants, func(want string) bool { |
| 87 | return strings.Contains(msg, want) |
| 88 | }) |
| 89 | if index != -1 { |
| 90 | fd.wants = slices.Delete(fd.wants, index, index+1) |
| 91 | return |
| 92 | } |
| 93 | } |
| 94 | if _, ok := pc.exemptions[pc.positionKey(pos)]; ok { |
| 95 | return // Ignored, not counted. |
| 96 | } |
| 97 | if !enableWrappers && !pos.IsValid() { |
| 98 | return // Ignored, implicit. |
| 99 | } |
| 100 | pc.pass.Reportf(pos, fmtStr, args...) |
| 101 | } |
| 102 | |
| 103 | // checkFailure checks for the expected failure counts. |
| 104 | func (pc *passContext) checkFailures() { |
no test coverage detected