New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
runtime: FuncForPC FileLine returns autogenerated instead of actual path #51774
Comments
Bisects to CL 388794 (I was curious). |
CC @cherrymui |
I'm not really sure what the right answer to be here. Technically this function is indeed autogenerated, as it is a closure capturing the receiver. This is also seen in the synthetic name ( We may be able to restore the old behavior, but I'm not sure that is best. If we want to give the location of the definition, perhaps we also want to give the original method name instead of the synthetic If you use the method that does not capture the receiver, like
It prints the actual line number. Would that be okay? Thanks. |
In my case using If there is a workaround or a more reliable solution to resolve arbitrary function into a place of origin in code, I would be happy to use it. |
This is also affecting https://github.com/go-chai/chai, which is a http router extension that generates a swagger spec based on the new generics. It used to work with go1.18beta2. The way I use it is chai.Get(r, "/{id}", controller.SomeHandler) runtime.FuncForPC then finds the file and line where SomeHandler is defined so it could use the AST and parse some swagger annotations from the comment above that function. Now it returns I wonder how Delve figures out the line numbers of functions when debugging and if it can be used for this sort of thing. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I was getting file and line of struct method.
https://go.dev/play/p/VFs8FKAkTLf
What did you expect to see?
What did you see instead?
The issue is reproducible with
go1.18
andgotip
, howevergo1.18rc1
and below (go1.17
) works as expected.The text was updated successfully, but these errors were encountered: