From 215b736fe11f08dcc53f3e407e5ebb9b695f738b Mon Sep 17 00:00:00 2001 From: Jinzhu Date: Mon, 4 Nov 2013 07:58:40 +0800 Subject: [PATCH] Ignore unexported field --- model.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/model.go b/model.go index 9e068c35..1b578734 100644 --- a/model.go +++ b/model.go @@ -3,10 +3,10 @@ package gorm import ( "errors" "fmt" + "go/ast" "reflect" "regexp" "strconv" - "time" ) @@ -82,7 +82,7 @@ func (m *Model) fields(operation string) (fields []Field) { for i := 0; i < typ.NumField(); i++ { p := typ.Field(i) - if !p.Anonymous { + if !p.Anonymous && ast.IsExported(p.Name) { var field Field field.Name = p.Name field.DbName = toSnake(p.Name)