If you use interface based design it is repeated through out the code with no way to write a performant generic method.
I am not a big fan of ‘reduced lines of code’ creating obscurity the hallmark of Go. In this case I think being able to pass a slice as an read only [] of interface makes MORE sense - since if the slice was not read only, in your case you need to add another 3 lines to copy the slice back… (and you might even need to do some merge/replace code) so a minimum of 6 lines for every method call (although if the calls were all of the same interface type, you would only have 3 at the front and 3 at the end). It is not a good coding style IMO, and fixing it would be backwards compatible and trivial. Sorry but we’ll probably disagree here. > On Oct 31, 2018, at 11:21 AM, Space A. <reexist...@gmail.com> wrote: > > It's already trivial 3 lines o code. Readable, light, and simple. > > And it's a question tbh, if topic starter even needs that code, or just a bad > implementation. > > > среда, 31 октября 2018 г., 18:47:37 UTC+3 пользователь Jake Montgomery > написал: > It is highly likely that when go2 comes out, with generics, it will be > trivial to write a ToInterfaceSlice() function that takes a slice of any type > T and returns a []interface{}. > > > -- > 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+unsubscr...@googlegroups.com > <mailto:golang-nuts+unsubscr...@googlegroups.com>. > For more options, visit https://groups.google.com/d/optout > <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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.