From dd1454689c6ad87766d11e29cac8b4ff528bc943 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxime=20Soul=C3=A9?= Date: Fri, 23 Jun 2023 10:36:43 +0200 Subject: [PATCH] refactor: standardize/simplify code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maxime Soulé --- td/check_test.go | 9 +++------ td/td_struct.go | 4 ++-- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/td/check_test.go b/td/check_test.go index 1ea683e3..d9641dcf 100644 --- a/td/check_test.go +++ b/td/check_test.go @@ -369,10 +369,9 @@ func checkOK(t *testing.T, got, expected any, func checkOKOrPanicIfUnsafeDisabled(t *testing.T, got, expected any, args ...any, -) bool { +) (ret bool) { t.Helper() - var ret bool cmp := func() { t.Helper() ret = _checkOK(t, got, expected, args...) @@ -385,7 +384,7 @@ func checkOKOrPanicIfUnsafeDisabled(t *testing.T, got, expected any, } cmp() - return ret + return } func checkOKForEach(t *testing.T, gotList []any, expected any, @@ -406,9 +405,7 @@ func checkOKForEach(t *testing.T, gotList []any, expected any, return } -func equalTypes(t *testing.T, got td.TestDeep, expected any, - args ...any, -) bool { +func equalTypes(t *testing.T, got td.TestDeep, expected any, args ...any) bool { gotType := got.TypeBehind() expectedType, ok := expected.(reflect.Type) diff --git a/td/td_struct.go b/td/td_struct.go index f41e02f8..0d20f923 100644 --- a/td/td_struct.go +++ b/td/td_struct.go @@ -200,7 +200,7 @@ func mergeStructFields(sfs ...StructFields) StructFields { } } -func newStruct(model any, strict bool) (*tdStruct, reflect.Value) { +func newStruct(model any) (*tdStruct, reflect.Value) { vmodel := reflect.ValueOf(model) st := tdStruct{ @@ -237,7 +237,7 @@ func newStruct(model any, strict bool) (*tdStruct, reflect.Value) { } func anyStruct(model any, expectedFields StructFields, strict bool) *tdStruct { - st, vmodel := newStruct(model, strict) + st, vmodel := newStruct(model) if st.err != nil { return st }