From 5de5170e0fe65c3e68acb00f0905bb517c9885a2 Mon Sep 17 00:00:00 2001 From: Jinzhu Date: Wed, 1 Dec 2021 17:12:38 +0800 Subject: [PATCH] Fix copier on v1.13 --- .github/workflows/tests.yml | 2 +- copier.go | 5 ++++- go.mod | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 2aa6f61..774b29c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -12,7 +12,7 @@ jobs: ci: strategy: matrix: - go: ['1.15', '1.14', '1.13'] + go: ['1.16', '1.17'] platform: [ubuntu-latest, macos-latest] # can not run in windows OS runs-on: ${{ matrix.platform }} diff --git a/copier.go b/copier.go index 246bfed..6d21da8 100644 --- a/copier.go +++ b/copier.go @@ -348,7 +348,10 @@ func deepFields(reflectType reflect.Type) []reflect.StructField { for i := 0; i < reflectType.NumField(); i++ { v := reflectType.Field(i) - if v.IsExported() { + // PkgPath is the package path that qualifies a lower case (unexported) + // field name. It is empty for upper case (exported) field names. + // See https://golang.org/ref/spec#Uniqueness_of_identifiers + if v.PkgPath == "" { if v.Anonymous { fields = append(fields, deepFields(v.Type)...) } else { diff --git a/go.mod b/go.mod index 531422d..309801e 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,3 @@ module github.com/jinzhu/copier -go 1.15 +go 1.13