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