Skip to content

Commit

Permalink
fix lints
Browse files Browse the repository at this point in the history
  • Loading branch information
ldemailly committed Nov 5, 2023
1 parent 73ac291 commit a3f8334
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion env.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,9 @@ func checkEnv(envName, fieldName string, fieldValue reflect.Value) *string {
func SetFromEnv(prefix string, s interface{}) []error {
return setFromEnv(nil, prefix, s)
}

func setFromEnv(allErrors []error, prefix string, s interface{}) []error {
// TOOD: this is quite similar in structure to structToEnvVars() - can it be refactored with
// TODO: this is quite similar in structure to structToEnvVars() - can it be refactored with
// passing setter vs getter function and share the same iteration (yet a little bit of copy is the go way too)
v := reflect.ValueOf(s)
// if we're passed a pointer to a struct instead of the struct, let that work too
Expand Down
5 changes: 4 additions & 1 deletion env_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,10 @@ func TestSetFromEnv(t *testing.T) {
for _, e := range envs {
os.Setenv(e.k, e.v)
}
struct2env.SetFromEnv("TST2_", &foo)
errors := struct2env.SetFromEnv("TST2_", &foo)
if len(errors) != 0 {
t.Errorf("Unexpectedly got errors :%v", errors)
}
assert.Equal(t, foo.Foo, "another\nfoo")
assert.Equal(t, foo.Bar, "bar")
assert.Equal(t, foo.RecurseHere.InnerB, "in1")
Expand Down

0 comments on commit a3f8334

Please sign in to comment.