From 55fcca661e44b497df014d4d15ed694504412b25 Mon Sep 17 00:00:00 2001 From: Gregory Eremin Date: Mon, 9 Jul 2018 00:46:43 +0200 Subject: [PATCH] Hope it works --- reflect2/fields.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/reflect2/fields.go b/reflect2/fields.go index ccbdc5f..96e0c68 100644 --- a/reflect2/fields.go +++ b/reflect2/fields.go @@ -25,3 +25,11 @@ func AssociateColumns(typ reflect.Type, tag string, cols []string) map[int]int { } return colFields } + +// Dereference keeps dereferencing pointers until a value is found. +func Dereference(val reflect.Value) reflect.Value { + for val.Kind() == reflect.Ptr && val.CanAddr() { + val = val.Elem() + } + return val +}