Skip to content

Commit e46ce41

Browse files
committed
test: add a test to check if param type of hook func could be type of func
1 parent f25d514 commit e46ce41

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

pkg/data/test_error.json

+6
Original file line numberDiff line numberDiff line change
@@ -106,5 +106,11 @@
106106
"Function": "BadDep",
107107
"OnExit": "onExitBadDep",
108108
"Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/test/error17"
109+
},
110+
{
111+
"ImportPath": "errorstest/auxiliary",
112+
"Function": "TargetWithFuncType",
113+
"OnEnter": "onEnterTargetWithFuncType",
114+
"Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/test/error18"
109115
}
110116
]

pkg/rules/test/error18/hook.go

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright (c) 2025 Alibaba Group Holding Ltd.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package error18
16+
17+
import (
18+
"github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/api"
19+
)
20+
21+
func onEnterTargetWithFuncType(call api.CallContext, _ interface{}) {
22+
}

test/errorstest/auxiliary/helper.go

+4
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,7 @@ func OnlyArgs(arg1 int, arg2 string) {
4343
println(arg1, arg2)
4444
}
4545
func NilArg(arg1 *int) {}
46+
47+
type Fn func()
48+
49+
func TargetWithFuncType(fn ...Fn) {}

0 commit comments

Comments
 (0)