FAQ
Thanks! Someone just pointed me to this discussion:
https://codereview.appspot.com/5321061.
On Monday, April 27, 2015 at 4:37:10 PM UTC-4, w...@fastmail.fm wrote:

There's a test checking that two errors are different:

errors.New("abc") == errors.New("abc")

This is because errors.New() creates errors with:

return &errorString{text}

Each error should therefore have its own unique address. I don't know why
errorString is a struct, probably to provide flexibility for future
extension.

On Mon, Apr 27, 2015, at 04:16 PM, Alex Gleyzer wrote:

I am curious why stringError is implemented as a struct not as simple
string:

https://github.com/golang/go/blob/439b32936367c3efd0dadab48dd51202e1a510f1/src/errors/errors.go#L14

I see there's a test checking that two errors with the same text are not
considered equal:

https://github.com/golang/go/blob/439b32936367c3efd0dadab48dd51202e1a510f1/src/errors/errors_test.go#L14

What's the reasoning behind that?

Thanks,
Alex


--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to golang-nuts...@googlegroups.com <javascript:>.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 3 of 4 | next ›
Discussion Overview
groupgolang-nuts @
categoriesgo
postedApr 27, '15 at 8:16p
activeApr 28, '15 at 5:12a
posts4
users3
websitegolang.org

3 users in discussion

Alex Gleyzer: 2 posts Wyc: 1 post Minux: 1 post

People

Translate

site design / logo © 2022 Grokbase