golangci-lint/test/testdata/exhaustruct.go
Anton Zinovyev 380699a099
feat: add exhaustruct linter (#2667)
Co-authored-by: Fernandez Ludovic <ldez@users.noreply.github.com>
2022-04-30 12:48:16 +02:00

48 lines
664 B
Go

// args: -Eexhaustruct
package testdata
import "time"
type Exhaustruct struct {
A string
B int
c bool // private field inside the same package are not ignored
D float64
E time.Time
}
func exhaustruct() {
// pass
_ = Exhaustruct{
A: "a",
B: 0,
c: false,
D: 1.0,
E: time.Now(),
}
// failPrivate
_ = Exhaustruct{ // ERROR "c is missing in Exhaustruct"
A: "a",
B: 0,
D: 1.0,
E: time.Now(),
}
// fail
_ = Exhaustruct{ // ERROR "B is missing in Exhaustruct"
A: "a",
c: false,
D: 1.0,
E: time.Now(),
}
// failMultiple
_ = Exhaustruct{ // ERROR "B, D are missing in Exhaustruct"
A: "a",
c: false,
E: time.Now(),
}
}