Hacker News new | past | comments | ask | show | jobs | submit login

I have a question about go. Let's say I have a struct Foo and a function/method for Less. What is the quickest way to sort an array of Foo's?

Do I have to implement my own []Foo type with all three methods as described in the sort package?





So the answer is yes, I have to implement the whole interface?


Yes, to use code that relies on an interface you must implement the interface for your types.

That is one of the reasons go has a guiding design principle that interfaces should be as small as possible.


Yes, generics are not (yet??) possible in go




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: