空接口
1 注意下面这样用空接口的时候,类型无法传递
package main import "fmt" func main() { a := [][]string{{"a","b","c"}} fmt.Println(a) test1(a) // interface{}可以接受任意类型,但这里不能这样传递,要把test2的接受类型改为interface{}才行, //test2(a) b := [][]interface{}{{"m","n"}} test2(b) } func test1([][]string) { println("test1") } func test2([][]interface{}) { println("test2") }
参考:https://sanyuesha.com/2017/07/22/how-to-understand-go-interface/