Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix typos in defaultTypeParsers #108

Merged
merged 2 commits into from
Feb 25, 2020
Merged
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
4 changes: 2 additions & 2 deletions env.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,14 @@ var (
reflect.TypeOf(url.URL{}): func(v string) (interface{}, error) {
u, err := url.Parse(v)
if err != nil {
return nil, fmt.Errorf("unable parse URL: %v", err)
return nil, fmt.Errorf("unable to parse URL: %v", err)
}
return *u, nil
},
reflect.TypeOf(time.Nanosecond): func(v string) (interface{}, error) {
s, err := time.ParseDuration(v)
if err != nil {
return nil, fmt.Errorf("unable to parser duration: %v", err)
return nil, fmt.Errorf("unable to parse duration: %v", err)
}
return s, err
},
Expand Down
6 changes: 3 additions & 3 deletions env_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -572,15 +572,15 @@ func TestInvalidDuration(t *testing.T) {
defer os.Clearenv()

cfg := Config{}
assert.EqualError(t, Parse(&cfg), "env: parse error on field \"Duration\" of type \"time.Duration\": unable to parser duration: time: invalid duration should-be-a-valid-duration")
assert.EqualError(t, Parse(&cfg), "env: parse error on field \"Duration\" of type \"time.Duration\": unable to parse duration: time: invalid duration should-be-a-valid-duration")
}

func TestInvalidDurations(t *testing.T) {
os.Setenv("DURATIONS", "1s,contains-an-invalid-duration,3s")
defer os.Clearenv()

cfg := Config{}
assert.EqualError(t, Parse(&cfg), "env: parse error on field \"Durations\" of type \"[]time.Duration\": unable to parser duration: time: invalid duration contains-an-invalid-duration")
assert.EqualError(t, Parse(&cfg), "env: parse error on field \"Durations\" of type \"[]time.Duration\": unable to parse duration: time: invalid duration contains-an-invalid-duration")
}

func TestParseStructWithoutEnvTag(t *testing.T) {
Expand Down Expand Up @@ -981,7 +981,7 @@ func TestParseInvalidURL(t *testing.T) {
}
var cfg config
os.Setenv("EXAMPLE_URL_2", "nope://s s/")
assert.EqualError(t, Parse(&cfg), "env: parse error on field \"ExampleURL\" of type \"url.URL\": unable parse URL: parse nope://s s/: invalid character \" \" in host name")
assert.EqualError(t, Parse(&cfg), "env: parse error on field \"ExampleURL\" of type \"url.URL\": unable to parse URL: parse nope://s s/: invalid character \" \" in host name")
}

func ExampleParse() {
Expand Down