i am using MethodByName in my go code to take the name of the function from config file, here i have declared the interface struct in other package but i want to call the function in other function,
log.Infof("\n name of metric is : " + metric.Name + "\n")
results := utils.Invoke(c, metric.Name, m, serviceLog, metric.TimeOut)
if !results[0].IsNil() {
log.Errorf("Failed to get " + metric.Name)
}
location of this file is /src/file1
func Invoke(any interface{}, name string, args ...interface{}) []reflect.Value {
inputs := make([]reflect.Value, len(args))
for i, _ := range args {
inputs[i] = reflect.ValueOf(args[i])
}
result := reflect.ValueOf(any).MethodByName(name).Call(inputs)
return result
}
this is in src/utils/file2
package diagnosticDumps
type ThresholdFunc struct{}
this is in src/diagnosticDumps
but it is giving panic: reflect: call of reflect.Value.Call on zero Value
the function written is exported
func (t *ThresholdFunc) HotThreadMetric(some parameters) {
Aucun commentaire:
Enregistrer un commentaire