Skip to content

Print out more info#3

Merged
jvictorchen merged 2 commits intomasterfrom
print-out-more-info
Mar 3, 2017
Merged

Print out more info#3
jvictorchen merged 2 commits intomasterfrom
print-out-more-info

Conversation

@jvictorchen
Copy link

Print out the name of the requested type, and the ambiguous implementations when panicking. This will be helpful for debugging.

}
if len(impls) > 1 && i.options.PanicOnAmbiguity {
panic(fmt.Sprintf("Expect single matching implementation but found %v", len(impls)))
panic(fmt.Sprintf("Expected single matching implementation for type <%v> but found %v: %v", t, len(impls), impls))

Choose a reason for hiding this comment

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

Does reflect.Value stringify nicely for all types? The documentation for reflect.Value's String() method (https://golang.org/pkg/reflect/#Value.String) says "The fmt package treats Values specially. It does not call their String method implicitly but instead prints the concrete values they hold.", but your test seems to indicate it prints the type, so I don't know what to believe anymore.

Copy link
Author

Choose a reason for hiding this comment

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

Hmm not sure why fmt package is not doing what it says, but from what I see, Value is printed as where T is v's type. So that suggests fmt package is calling String() method?

@jvictorchen jvictorchen merged commit 78dabaf into master Mar 3, 2017
@jvictorchen jvictorchen deleted the print-out-more-info branch March 3, 2017 03:35
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.

2 participants