Skip to content

Unclear error message when multiple nested structs have fields with the same name #162

@vk-rv

Description

@vk-rv

When using nested structs with fields that have the same name, the error message doesn't specify which struct's field is missing, making it difficult to identify the source of the configuration error

type Config struct {
	A struct {
		Host string `env:"A_HOST" env-required:"true"`
	}
	B struct {
		Host string `env:"B_HOST" env-required:"true"`
	}
}
if err := cleanenv.ReadEnv(&cfg); err != nil {
// field "Host" is required but the value is not provided
}

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