Skip to content

Instantly share code, notes, and snippets.

@anjanashankar9
Created October 7, 2021 04:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anjanashankar9/3cbf70dde8d5e1f0d433f9d3208ad6bf to your computer and use it in GitHub Desktop.
Save anjanashankar9/3cbf70dde8d5e1f0d433f9d3208ad6bf to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"reflect"
)
type Employee struct {
firstName string
secondName string
id *int
}
func main() {
id1 := 1
id2 := 1
id3 := 1
e1 := Employee {
firstName: "Anjana",
secondName: "Shankar",
id: &id1,
}
e2 := Employee {
firstName: "Anjana",
secondName: "Shankar",
id: &id2,
}
e3 := Employee {
firstName: "Anjana",
secondName: "Shan",
id: &id3,
}
fmt.Println("== Operator in practice")
if e1 == e2 {
fmt.Println("e1 == e2")
} else {
fmt.Println("e1 != e2")
}
if e2 == e3 {
fmt.Println("e2 == e3")
} else {
fmt.Println("e2 != e3")
}
fmt.Println("DeepEqual() in practice")
fmt.Println("Is e1 equal to e2 : ", reflect.DeepEqual(e1, e2))
fmt.Println("Is e2 equal to e3 : ", reflect.DeepEqual(e2, e3))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment