We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
比较原则:
具体哪些可以比较,可以参看官方文档:Comparison operators
可以通过 reflect.DeepEqual 比较两个 slice/struct/map 是否相等
package main import ( "fmt" "reflect" ) type A struct { s string } func main() { a1 := A{s: "abc"} a2 := A{s: "abc"} if reflect.DeepEqual(a1, a2) { fmt.Println(a1, "==", a2) } b1 := []int{1, 2} b2 := []int{1, 2} if reflect.DeepEqual(b1, b2) { fmt.Println(b1, "==", b2) } c1 := map[string]int{"a": 1, "b": 2} c2 := map[string]int{"a": 1, "b": 2} if reflect.DeepEqual(c1, c2) { fmt.Println(c1, "==", c2) } }
在线演示地址: http://play.golang.org/p/SB8LeLNdA8
The text was updated successfully, but these errors were encountered:
No branches or pull requests
比较原则:
具体哪些可以比较,可以参看官方文档:Comparison operators
相同struct
不可比较
可以比较
不同struct
不可比较
可以比较
比较两个 slice/struct/map 是否相等
可以通过 reflect.DeepEqual 比较两个 slice/struct/map 是否相等
在线演示地址: http://play.golang.org/p/SB8LeLNdA8
Reference
The text was updated successfully, but these errors were encountered: