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

Use fmt.Stringer or encoding.TextMarshaler if possible #19

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

otaku
Copy link

@otaku otaku commented Dec 26, 2014

An implementation for /issues/16 but also includes fmt.Stringer with priority given to Stringer before TextMarshaler.

I copied /pull/17 test implementation and added two other test cases.

if v.CanInterface() {
switch v.Interface().(type) {
case fmt.Stringer:
p.fmtString(v.Interface().(fmt.Stringer).String(), true)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Assign a value on line 172 and I will be typed in each case so this line would reduce to p.fmtString(v.String(), true) and the other case would be simplified similarly.

@otaku
Copy link
Author

otaku commented Dec 26, 2014

One thing about this though is this will hide the actual fields, but generally it's helpful in cases such as time.Time. Would it be helpful to add prefix in for these cases?
"&time.Time{(Stringer) "2013-10-01 00:00:00 +0000 UTC"},

@ruzz311
Copy link

ruzz311 commented Aug 26, 2015

+1 or can it use GoStringer?

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.

None yet

3 participants