golang 获取变量类型的字符串格式 列举变量类型

fmt.Println(reflect.TypeOf(var)) 

switch xxx.(type){

  case int:....

  case float32:...

  case float64:...

  case string:...

}

对type的枚举,不能使用fallthrough,且float32和float64是两个不同的类型(没有单独的float类型),而int却包含int64

猜你喜欢

转载自www.cnblogs.com/Denny_Yang/p/8985000.html