package main
import (
"fmt"
)
type Column struct {
Name string `json:"name"`
Type string `json:"type"`
}
func main() {
a := []*Column{
{Name: "a", Type: "int"},
{Name: "b", Type: "int"},
}
b := []*Column{
{Name: "a", Type: "int"},
{Name: "c", Type: "string"},
}
c := []*Column{
{Name: "a", Type: "string"},
{Name: "d", Type: "int"},
}
}
比较 2 个对象列表时需要查找是否有重叠的 Name 和不同的 Type,如果没有则返回 false。对优化逻辑有什么建议吗?
func check(obj1,obj2){
// when comparing a and b it would return false as both Name="a" has identical Type="int"
// when comparing b and c it would return true as both Name="a" have different Types
}
撒科打诨
相关分类