Skip to content

no errors if default value doesn't parse #7

@ansel1

Description

@ansel1

If the value in the default tag is not parseable as the type of the field, there is no error returned. Is this intended? For example:

type Widget struct {
  Colors []string `env:"[red,blue]"`
}

func main() {
  var c Colors
  err := defaults.Set(&c)

  fmt.Println("err: ", err) // nothing printed, no error

  fmt.Println(c.Colors) // nothing printed, tag value was not valid JSON, so parsing silently failed
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions