forked from LS6-Events/astra
-
Notifications
You must be signed in to change notification settings - Fork 0
/
callExpression.go
86 lines (63 loc) · 1.57 KB
/
callExpression.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
package testfiles
// Example call expression with ranging number of arguments and return types
import (
"fmt"
"strings"
"github.com/Mrzrb/astra/astTraversal/testfiles/otherpkg1"
)
func NoArgs() {
fmt.Println("Function with no arguments.")
}
func callExpr() {
// Direct function calls
fmt.Println("Hello, World!")
// Variable declaration & method call on standard library types
str := "LS6 Events"
strings.Contains(str, "LS6")
// Regular function call with multiple arguments
TestFunction(5, "LS6")
// Method calls on user-defined types
ms := MyStruct{Name: "MyStruct"}
ms.SayHello()
// Call to a function with no arguments
NoArgs()
// Call to a function with a response
result := TestFunction(10, "OpenAI")
// Call to a function with more than 1 response
result2, err := otherpkg1.GetFoo()
fmt.Println(result, result2, err)
}
func TestFunction(a int, b string) string {
return fmt.Sprintf("%d - %s", a, b)
}
func contextFuncBuilderTest() error {
err := contextFuncBuilderIgnored(nil)
if err != nil {
return err
}
err = contextFuncBuilderStatusCode(200)
if err != nil {
return err
}
err = contextFuncBuilderExpressionResult(MyStruct{Name: "foo"})
if err != nil {
return err
}
err = contextFuncBuilderValue("bar")
if err != nil {
return err
}
return nil
}
func contextFuncBuilderIgnored(param any) error {
return nil
}
func contextFuncBuilderStatusCode(statusCode int) error {
return nil
}
func contextFuncBuilderExpressionResult(expression MyStruct) error {
return nil
}
func contextFuncBuilderValue(value string) error {
return nil
}