summaryrefslogtreecommitdiff
path: root/src/mongo/gotools/vendor/src/github.com/3rf/mongo-lint/testdata/errorf.go
blob: 768fb8ce60f9bd65f6439edb3889652e58f4cc04 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// Test for not using fmt.Errorf.

// Package foo ...
package foo

import (
	"errors"
	"fmt"
)

func f(x int) error {
	if x > 10 {
		return errors.New(fmt.Sprintf("something %d", x)) // MATCH /should replace.*errors\.New\(fmt\.Sprintf\(\.\.\.\)\).*fmt\.Errorf\(\.\.\.\)/
	}
	if x > 5 {
		return errors.New(g("blah")) // ok
	}
	if x > 4 {
		return errors.New("something else") // ok
	}
	return nil
}