草庐IT

ormInstance

全部标签

go - 消除类型转换中的重复代码

由于我不能在类型切换中使用fallthrough,有什么办法可以在这段代码中合并这两种情况吗?switchv:=moduleSource.(type){caseDriver:dec.Decode(&v)_,_=ormInstance.Insert(&v)caseMetric:dec.Decode(&v)_,_=ormInstance.Insert(&v)default:fmt.Println("unknowntype")}ORM调用ormInstance.Insert()必须具有正确的结构才能正常工作。 最佳答案 类型开关中允许使用