To answer the first point - the keyword is "*assignable*" here - an slice 
[]int{1,23} is not assignable to a slice []I where I is a type of int. 
See https://golang.org/ref/spec#Assignability 

( also golang treats slices as types in themselves 
ie https://golang.org/ref/spec#SliceType )

..However..

This or very similar has definitely been asked before (including by me I'm 
sure, maybe I should try to find the thread) - it does seem reasonable and 
useful - but it doesn't work (and may never)

 for example your suggestion would work very well with the whole fmt 
package - which often takes []interface as parameters, and then reflects on 
that array to find type .. however passing []int etc doesn't currently 
work, and requires an 'annoying' intermediate assign of each element to the 
interfacial struct.

Some links to previous discussions (of the more general case using 
[]interface{} as the receiving type)

https://groups.google.com/forum/#!topic/golang-nuts/0qWnorUuct8

and

https://groups.google.com/forum/#!topic/golang-nuts/yZqFmd7z82Y

had reasonable discussions - the second also points out that this is 
covered in the FAQ - maybe around 
here https://golang.org/doc/faq#convert_slice_of_interface


Personally I'd like to see this implemented too - it has good use.

-- 
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.

Reply via email to