Can two instances of the same struct be compared == !=
Answer: yes or no
Can two different instances of struct be compared == !=
Answer: yes or no
If all the member variables of the structure are comparable, then the structure can be compared.
If there are incomparable member variables in the structure, then the structure cannot be compared
type s2 struct { name string } aa: = s2{ name: " aa " , } bb: = s2{ name: " aa " , } fmt.Printf( " %v\n " , aa == bb)
This returns true
If it is a structure pointer, return false
When there are incomparable fields, an error will be reported at compile time
Change to a structure pointer, there will be no error
Return result false; true
Code:
type s1 struct { one map[ string ] string two [] string three string } a: = & s1{ one: map[ string ] string { " aaa " : " bbb " }, two: [] string { " aaa " , " bbb " }, three: " aaaa " , } b: = & s1{ one: map[ string ] string { " aaa " : " bbb " }, two: [] string { " aaa " , " bbb " }, three: " aaaa " , } c : = a fmt.Printf( " %v;%v " , a == b, a == c)
Read More:
- Golang: How to determine structure whether it is empty
- [Solved] TypeError: Converting circular structure to JSON – JSON.stringify
- How to Solve Converting circular structure to JSON‘ Error
- How to Solve “Vue is not defined” Error
- [Solved] JQuery each Method Error: $XXX is not defined
- [Solved] Vuepress Package Error: document is not defined
- [Solved] vite package Error: globalThis is not defined
- vue eslint error ‘process‘ is not defined no-undef [How to Solve]
- [Solved] Vue 3 Script Setup ESLint Error: ‘defineProps‘ is not defined
- [Solved] Uncaught ReferenceError: axios is not defined
- Vuepress build error: window is not defined [How to Solve]
- Ant design vue table Error: h is not defined [How to Solve]
- [Solved] Vue item error: Regeneratorruntime is not defined
- [Solved] vite2+vue3 jsx Error: React is not defined
- [Solved] Nuxt Import qrcodejs2.js / QRCode.js Error: document is not defined
- “Failed to load resource: net::ERR_FILE_NOT_FOUND” error. The project created by vue-cli 3.0 can run under dev, and an error is reported after packaging, and the page is blank.
- [Solved] Vue3 process Error: Uncaught ReferenceError: process is not defined
- [Solved] Vue3 Configuration routing error: Catch all routes (“*“) must now be defined using a param with a custom regexp.
- [Solved] Vue Error: error: ‘to‘ is defined but never used (no-unused-vars)
- vue error: ‘ev’ is defined but never used (no-unused-vars)