From 61760281767f2ccbda6046bce03d1b137b5e7508 Mon Sep 17 00:00:00 2001 From: John Guo Date: Wed, 18 May 2022 17:57:16 +0800 Subject: [PATCH] improve package gmeta --- util/gmeta/gmeta.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/util/gmeta/gmeta.go b/util/gmeta/gmeta.go index 9ee4d8610..936a22d4f 100644 --- a/util/gmeta/gmeta.go +++ b/util/gmeta/gmeta.go @@ -16,8 +16,8 @@ import ( type Meta struct{} const ( - // metaAttributeName is the attribute name of metadata in struct. - metaAttributeName = "Meta" + metaAttributeName = "Meta" // metaAttributeName is the attribute name of metadata in struct. + metaTypeName = "gmeta.Meta" // metaTypeName is for type string comparison. ) // Data retrieves and returns all metadata from `object`. @@ -27,7 +27,9 @@ func Data(object interface{}) map[string]string { return nil } if field, ok := reflectType.FieldByName(metaAttributeName); ok { - return gstructs.ParseTag(string(field.Tag)) + if field.Type.String() == metaTypeName { + return gstructs.ParseTag(string(field.Tag)) + } } return map[string]string{} }