I want to create map which stores routes from one point to another, distance between them will be used as values in the map.
type Route struct {
start string
finish string
}
m := make(map[Route]int)
v := Route{start: "A",
finish: "B"}
m[v] = 42
Distance from A to B equals to distance from B to A.
w := Route{start: "B",
finish: "A"}
How can I get m[w] without pushing m[w] = 42 into the map again because v and w are the same route.
P.S In other words, is it possible to override rules when one Route equals to another Route when using Route as a key in map?
Route. You need to come up with a type that is the same for both.Routeequals to anotherRoute?