多态用法 package main //一种事物的多种形态,都可以按照统一的接口进行操作 //多态 import ( "fmt" "math/rand" "sort" ) type Student struct { Name string Id string Age int sortType int } type Book struct { Name string Author string } //切片默认传地址 type StudentArr…
原文链接:https://www.2cto.com/kf/201712/703563.html 1. 用于判断变量类型 demo如下: switch t := var.(type){ case string: //add your operations case int8: //add your operations case int16: //add your operations default: return errors.New("no this type") } } //空接…