go泛型
作者:互联网
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) }
标签:val,fmt,PrintAll,泛型,range,names,go,vals 来源: https://www.cnblogs.com/hnxxcxg/p/15265859.html