Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions envconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,11 +203,7 @@ func Process(prefix string, spec interface{}) error {
req := info.Tags.Get("required")
if !ok && def == "" {
if isTrue(req) {
key := info.Key
if info.Alt != "" {
key = info.Alt
}
return fmt.Errorf("required key %s missing value", key)
return fmt.Errorf("required key %s missing value", info.Key)
}
continue
}
Expand Down
6 changes: 3 additions & 3 deletions envconfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,7 @@ func TestCheckDisallowedIgnored(t *testing.T) {

func TestErrorMessageForRequiredAltVar(t *testing.T) {
var s struct {
Foo string `envconfig:"BAR" required:"true"`
Foo string `envconfig:"BAR" required:"true"`
}

os.Clearenv()
Expand All @@ -804,8 +804,8 @@ func TestErrorMessageForRequiredAltVar(t *testing.T) {
t.Error("no failure when missing required variable")
}

if !strings.Contains(err.Error(), " BAR ") {
t.Errorf("expected error message to contain BAR, got \"%v\"", err)
if !strings.Contains(err.Error(), " ENV_CONFIG_BAR ") {
t.Errorf("expected error message to contain ENV_CONFIG_BAR, got \"%v\"", err)
}
}

Expand Down