Skip to content

Repository files navigation

lesiw.io/testcmp

Go Reference CI Release Go Version Discord License

An analysis.Analyzer that reports uses of reflect.DeepEqual in tests.

DeepEqual is not configurable: unexported fields are always compared, a nil slice never equals an empty one, and NaN never equals itself. A comparator such as go-cmp lets a test say what equal means and shows what differed.

Checks

reflect.DeepEqual in a test

if !reflect.DeepEqual(a, b) { // avoid reflect.DeepEqual in tests; consider go-cmp
    t.Errorf("got %v, want %v", a, b)
}

Production (non-test) uses of reflect.DeepEqual are not reported, and only package-qualified calls are matched — a dot import or a function value is not.

Usage

go get -tool lesiw.io/testcmp/cmd/testcmp
go tool testcmp ./...

About

An analysis.Analyzer that keeps test comparisons on go-cmp.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages