On Mon, Feb 5, 2018 at 1:13 PM, Chris Hopkins wrote:
> Well, the first allows one Less per package, the second allows one per
> type.
>
No, the first allows an arbitrary number of Less' per package or type and
the second one allows one per type.
You can call a function LessByName, LessByID, Less
Well, the first allows one Less per package, the second allows one per
type. Since I tend to have multiple types in a package I find that more
readable.
Anyway, I finally fixed the problem with mixture of reflect and type
assertion
val := reflect.ValueOf(b)
if val.Kind() == reflect.
I don't really see the difference in writing
func Less(a, b *T) bool
and
func (a *T) Less(b *T) bool
convenience wise - except that the latter requires the name to be exported
and doesn't allow using a function literal (so, yeah, the latter actually
seems significantly *less* convenient).
On Thu,
No, was hoping to use the interface (It's the only reason I defined it) to
test if two items are equal.
I guess I could enforce that you have to supply the equals function like
the sort interface does. I was just hoping for more.
I'll have a rethink next time I have time.
Thanks
On Thursday, 1
On Thu, Feb 1, 2018 at 11:52 AM, Chris Hopkins wrote:
> Yeah, so having played with this. It seems that this is going to take some
> judicious use of reflect if I'm to stand any chance of maintaining a
> flexible API, which I really hoped to avoid.
>
I'm 99% sure that you don't have to use refle
For issue tracker reports these questions are asked:
What did you do?
What did you expect to see?
What did you see instead?
Please describe your API needs in more detail. Interfaces are useful for
API design but it appears we may be misunderstanding what your interface
type assertion needs ar
Yeah, so having played with this. It seems that this is going to take some
judicious use of reflect if I'm to stand any chance of maintaining a
flexible API, which I really hoped to avoid.
I had assumed that the point of interfaces was to avoid this. I guess from
a high level I don't see why a s
also notice, if you haven’t encountered it, this makes []interfaces a bit
awkward to handle with ellipsis functions...
https://play.golang.org/p/JWuc4jt2uSP
what i do is this;
https://play.golang.org/p/O9Q4K_vXlul
but you will need a convert for all combinations of interfaces and ellipsis
fu