Skip to main content
fix typo
Source Link
akira
  • 6.1k
  • 30
  • 37

Your value is already a pointer to a struct. Try printing out s.Kind() in your code.

There's no reason to take the address osof value, then call Elem() on that reflect.Value, which dereferences the pointer you just created.

s := reflect.ValueOf(value).Elem()
metric := s.FieldByName(subvalMetric).Interface()
fmt.Println(metric)

Your value is already a pointer to a struct. Try printing out s.Kind() in your code.

There's no reason to take the address os value, then call Elem() on that reflect.Value, which dereferences the pointer you just created.

s := reflect.ValueOf(value).Elem()
metric := s.FieldByName(subvalMetric).Interface()
fmt.Println(metric)

Your value is already a pointer to a struct. Try printing out s.Kind() in your code.

There's no reason to take the address of value, then call Elem() on that reflect.Value, which dereferences the pointer you just created.

s := reflect.ValueOf(value).Elem()
metric := s.FieldByName(subvalMetric).Interface()
fmt.Println(metric)
Source Link
JimB
  • 108.1k
  • 17
  • 277
  • 267

Your value is already a pointer to a struct. Try printing out s.Kind() in your code.

There's no reason to take the address os value, then call Elem() on that reflect.Value, which dereferences the pointer you just created.

s := reflect.ValueOf(value).Elem()
metric := s.FieldByName(subvalMetric).Interface()
fmt.Println(metric)