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

feat(parsing): Added encoding.TextUnmarshaler support #53

Merged
merged 1 commit into from
Jul 2, 2018

Conversation

stevenh
Copy link
Contributor

@stevenh stevenh commented Jun 29, 2018

Support arbitrary types by adding the ability to deserialize environment variables on any type that implements encoding.TextUnmarshaler.

This avoids the overhead of having to write custom parser funcs.

Also:

  • Eliminate duplicate handleStruct method.
  • Use fmt.Errorf instead of errors.New with concatenated strings.

@ghost
Copy link

ghost commented Jun 29, 2018

There were the following issues with this Pull Request

  • Commit: 036d649
    • ✖ message may not be empty
      , - ✖ type may not be empty

You may need to change the commit messages to comply with the repository contributing guidelines.


🤖 This comment was generated by commitlint[bot]. Please report issues here.

Happy coding!

env.go Outdated
@@ -122,7 +123,7 @@ func get(field reflect.StructField) (string, error) {
case "required":
val, err = getRequired(key)
default:
err = errors.New("Env tag option " + opt + " not supported.")
err = fmt.Errorf("Env tag option %q not supported.", opt)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

error strings should not be capitalized or end with punctuation or a newline

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, but I didn't add them and they are all through the code so didn't want to pollute the functionality of this commit with those changes.

@coveralls
Copy link

coveralls commented Jun 29, 2018

Coverage Status

Coverage increased (+0.1%) to 98.75% when pulling c4f2804 on stevenh:text-unmarshaler into 3e0f30c on caarlos0:master.

@stevenh stevenh force-pushed the text-unmarshaler branch from 036d649 to d1af6f5 Compare June 29, 2018 15:13
@ghost
Copy link

ghost commented Jun 29, 2018

There were the following issues with this Pull Request

  • Commit: d1af6f5
    • ✖ message may not be empty
      , - ✖ type may not be empty

You may need to change the commit messages to comply with the repository contributing guidelines.


🤖 This comment was generated by commitlint[bot]. Please report issues here.

Happy coding!

Support arbitrary types by adding the ability to deserialize environment variables on any type that implements encoding.TextUnmarshaler.

This avoids the overhead of having to write custom parser funcs.

Also:
* Eliminate duplicate handleStruct method.
* Use fmt.Errorf instead of errors.New with concatenated strings.
@stevenh stevenh force-pushed the text-unmarshaler branch from d1af6f5 to c4f2804 Compare June 29, 2018 15:20
@stevenh stevenh changed the title Added encoding.TextUnmarshaler support feat(parsing): Added encoding.TextUnmarshaler support Jun 29, 2018
@caarlos0
Copy link
Owner

caarlos0 commented Jul 2, 2018

that's super nice! Thanks @stevenh!

@caarlos0 caarlos0 merged commit bc122c2 into caarlos0:master Jul 2, 2018
@stevenh stevenh deleted the text-unmarshaler branch July 2, 2018 20:03
nexoscp added a commit to nexoscp/env that referenced this pull request Apr 7, 2022
feat(parsing): Added encoding.TextUnmarshaler support
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants