From 756fdfdd7985a8d5ac254ec85911e43e085ea02a Mon Sep 17 00:00:00 2001 From: northfun Date: Fri, 30 Oct 2020 09:44:23 +0800 Subject: [PATCH] Update 'tags/parser.go' Solve runtime problem:"panic: reflect.Value.Interface: cannot return value obtained from unexported field or method" --- tags/parser.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tags/parser.go b/tags/parser.go index add30a13..a7f16fa9 100644 --- a/tags/parser.go +++ b/tags/parser.go @@ -253,7 +253,7 @@ func (parser *Parser) Parse(v reflect.Value) (*schemas.Table, error) { addIndex(indexName, table, col, indexType) } } - } else { + } else if fieldValue.CanSet(){ var sqlType schemas.SQLType if fieldValue.CanAddr() { if _, ok := fieldValue.Addr().Interface().(convert.Conversion); ok { @@ -272,6 +272,8 @@ func (parser *Parser) Parse(v reflect.Value) (*schemas.Table, error) { if fieldType.Kind() == reflect.Int64 && (strings.ToUpper(col.FieldName) == "ID" || strings.HasSuffix(strings.ToUpper(col.FieldName), ".ID")) { idFieldColName = col.Name } + } else { + continue } if col.IsAutoIncrement { col.Nullable = false