Skip to content

Commit 6d09814

Browse files
committed
Ignore interface{} params when checking
1 parent 678b74a commit 6d09814

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

internal/fn/fn.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ func ParamsMatch(fn interface{}, skip int, args ...interface{}) bool {
4141
}
4242

4343
for i, arg := range args {
44+
// if target is interface{} skip
45+
if fnType.In(skip+i).Kind() == reflect.Interface {
46+
continue
47+
}
48+
4449
if fnType.In(skip+i) != reflect.TypeOf(arg) {
4550
return false
4651
}

internal/fn/fn_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,9 @@ func intParam(int) {
120120
func stringParam(string) {
121121
}
122122

123+
func interfaceParam(string, interface{}, int) {
124+
}
125+
123126
func mixedParams(context.Context, int, string) {
124127
}
125128

@@ -150,6 +153,13 @@ func TestParamsMatch(t *testing.T) {
150153
},
151154
want: false,
152155
},
156+
{
157+
name: "interface{} ignored",
158+
fn: func() bool {
159+
return ParamsMatch(interfaceParam, 0, "", 23, 42)
160+
},
161+
want: true,
162+
},
153163
{
154164
name: "mixed params",
155165
fn: func() bool {

0 commit comments

Comments
 (0)