From c9f628fb895ed2c3dcb39b138b7dc773e7256539 Mon Sep 17 00:00:00 2001 From: RSWilli Date: Mon, 25 Nov 2024 23:58:18 +0100 Subject: [PATCH] allow for "gst" struct tags to specify field name --- gst/gst_structure.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/gst/gst_structure.go b/gst/gst_structure.go index 6f10546..e33ab2c 100644 --- a/gst/gst_structure.go +++ b/gst/gst_structure.go @@ -83,7 +83,13 @@ func (s *Structure) UnmarshalInto(data interface{}) error { nVal := rv.Elem() for i := 0; i < val.NumField(); i++ { nvField := nVal.Field(i) - fieldName := val.Type().Field(i).Name + + fieldName, ok := val.Type().Field(i).Tag.Lookup("gst") + + if !ok { + fieldName = val.Type().Field(i).Name + } + val, err := s.GetValue(fieldName) if err == nil { nvField.Set(reflect.ValueOf(val))