go泛型
package main import ( "fmt" ) func PrintAll(vals []interface{}) { for _, val := range vals { fmt.Println(val) } } func main() { //names := []int{1, 2, 3} names := []string{"1", "2", "3"} vals := make([]interface{}, len(names)) for i, v := range names { vals[i] = v } PrintAll(vals) }