diff options
| author | Alex Flint <[email protected]> | 2021-01-31 18:46:05 -0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-01-31 18:46:05 -0800 |
| commit | 2a23168641ed1fb55f5f4dc72f50bdf15cb65b27 (patch) | |
| tree | eb5cf751ccfc98a9cdceb401c80afde1b4f406fe /reflect.go | |
| parent | b91c03d2c6c9e6429f3947f6b6e83321a56aa0f2 (diff) | |
| parent | aa6cb95149b650d07de76176d652b7280c86db06 (diff) | |
Merge pull request #136 from alexflint/ignore-unexported
Skip unexported fields
Diffstat (limited to 'reflect.go')
| -rw-r--r-- | reflect.go | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -3,6 +3,8 @@ package arg import ( "encoding" "reflect" + "unicode" + "unicode/utf8" scalar "github.com/alexflint/go-scalar" ) @@ -60,3 +62,9 @@ func isBoolean(t reflect.Type) bool { return false } } + +// isExported returns true if the struct field name is exported +func isExported(field string) bool { + r, _ := utf8.DecodeRuneInString(field) // returns RuneError for empty string or invalid UTF8 + return unicode.IsLetter(r) && unicode.IsUpper(r) +} |
