Skip to content

How do I call the method of the struct ? #1531

Answered by mvertes
lz520520 asked this question in Q&A
Discussion options

You must be logged in to vote

Because of some limitations of Go reflect packages, the resolution of methods can not be performed outside of the interpreter context. What works is the following:

v, err := intp.Eval("plugins_test.Test.Run") // Run method is obtained from within the interpreter, not reflect.
v.Call(nil)

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by mvertes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants
Converted from issue

This discussion was converted from issue #1346 on March 23, 2023 09:10.