Skip to content

Commit

Permalink
Merge pull request jinzhu#24 from Xzya/master
Browse files Browse the repository at this point in the history
Ignore unexported fields
  • Loading branch information
jinzhu authored Aug 25, 2017
2 parents 9ce39de + 882157d commit 7f729a6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions configor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ type Config struct {
}

Anonymous `anonymous:"true"`

private string
}

func generateDefaultConfig() Config {
Expand Down
4 changes: 4 additions & 0 deletions utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ func processTags(config interface{}, prefixes ...string) error {
envName = fieldStruct.Tag.Get("env") // read configuration from shell env
)

if !field.CanAddr() || !field.CanInterface() {
continue
}

if envName == "" {
envNames = append(envNames, strings.Join(append(prefixes, fieldStruct.Name), "_")) // Configor_DB_Name
envNames = append(envNames, strings.ToUpper(strings.Join(append(prefixes, fieldStruct.Name), "_"))) // CONFIGOR_DB_NAME
Expand Down

0 comments on commit 7f729a6

Please sign in to comment.