因为并非所有类型都具有可比性一片.所以我们不能这样做
原文链接:https://www.f2er.com/go/242080.htmlvar v ArbitraryType v == reflect.Zero(reflect.TypeOf(v)).Interface()
编辑 – 解决方案reflect.DeepEqual
var v ArbitratyType zero := reflect.Zero(reflect.TypeOf(v)).Interface() isZero := reflect.DeepEqual(v,zero)
去关于reflect.DeepEqual的文档
DeepEqual tests for deep equality. It uses normal == equality where possible but will scan elements of arrays,slices,maps,and fields of structs.