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

From method proposal #1

Closed
paganotoni opened this issue Jan 5, 2019 · 1 comment
Closed

From method proposal #1

paganotoni opened this issue Jan 5, 2019 · 1 comment

Comments

@paganotoni
Copy link

Hi Duffn 👋,

I was using your library this weekend and thought of an idea that i would like to present to you, and if you don't have the bandwidth i'm willing to put together a PR.

My idea is to have a function inside the library called NameFrom that will receive an interface{} and return a name.Name, something like:

From(person interface{}) (Name, error)

This function will return a name from any struct, to do so it will check that:

  • Passed person is a struct
  • It has FirstName and LastName fields

If so, it will create a Name instance with those field values and then library users could do something like:

n, _ := name.From(contact)
if (err != nil ){
 ...
}

n.FullName()

Thanks for taking the time to build this lib, and for reading until here.

@paganotoni paganotoni changed the title Person interface proposal From method proposal Jan 5, 2019
@paganotoni paganotoni reopened this Jan 5, 2019
@duffn
Copy link
Owner

duffn commented Jan 6, 2019

Hey @paganotoni! If you'd like to submit a PR, that would be great.

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

No branches or pull requests

2 participants