runtime: FuncForPc on reflect.Pointer() result does not work properly #57383
Labels
compiler/runtime
Issues related to the Go compiler and/or runtime.
WaitingForInfo
Issue is not actionable because of missing required information, which needs to be provided.
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
no
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
func (ctrl *BaseController) setFunc(f func(), father *BaseController) {
ctrl.rpcFunc = f
ctrl.http = &httpBase{Data: map[string]any{}}
ptr := reflect.ValueOf(f).Pointer()
functionInfo := runtime.FuncForPC(ptr)
file, line := functionInfo.FileLine(ptr)
file = file[strings.LastIndex(file, "/")+1:] //strings.ReplaceAll(file, utils.GetRuntimePath()+"/", "")
name := functionInfo.Name()
file = name[:strings.LastIndex(name, ".")]
file = file[:strings.LastIndex(file, ".")]
name = name[strings.LastIndex(name, ".")+1:]
ctrl.funcName = utils.CombineString(name[strings.LastIndex(name, ".")+1:], "(", file, ":", utils.AllToString(line), ")")
ctrl.father = father
}
What did you expect to see?
if use 1.17 this file and line return the value I want but now it work not well
it not return the function in witch file and line number
What did you see instead?
The text was updated successfully, but these errors were encountered: