From 7a49629fd1c7c35bd76df5016cd4193bf3db7d81 Mon Sep 17 00:00:00 2001 From: daheige Date: Wed, 14 Jul 2021 21:45:23 +0800 Subject: [PATCH] optimize Parse func for fieldValue.Interface --- schema/schema.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/schema/schema.go b/schema/schema.go index 4d5b7346..0e0501d4 100644 --- a/schema/schema.go +++ b/schema/schema.go @@ -244,19 +244,20 @@ func Parse(dest interface{}, cacheStore *sync.Map, namer Namer) (*Schema, error) } fieldValue := reflect.New(field.IndirectFieldType) - if fc, ok := fieldValue.Interface().(CreateClausesInterface); ok { + fieldInterface := fieldValue.Interface() + if fc, ok := fieldInterface.(CreateClausesInterface); ok { field.Schema.CreateClauses = append(field.Schema.CreateClauses, fc.CreateClauses(field)...) } - if fc, ok := fieldValue.Interface().(QueryClausesInterface); ok { + if fc, ok := fieldInterface.(QueryClausesInterface); ok { field.Schema.QueryClauses = append(field.Schema.QueryClauses, fc.QueryClauses(field)...) } - if fc, ok := fieldValue.Interface().(UpdateClausesInterface); ok { + if fc, ok := fieldInterface.(UpdateClausesInterface); ok { field.Schema.UpdateClauses = append(field.Schema.UpdateClauses, fc.UpdateClauses(field)...) } - if fc, ok := fieldValue.Interface().(DeleteClausesInterface); ok { + if fc, ok := fieldInterface.(DeleteClausesInterface); ok { field.Schema.DeleteClauses = append(field.Schema.DeleteClauses, fc.DeleteClauses(field)...) } }