From a6cd50834ce9c3dc62f0487f29b547dcb06a5382 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A4r=20Karlsson?= Date: Sun, 30 Jul 2017 17:35:18 +0200 Subject: [PATCH] better explanation of the reasoning behind inconsistent pointer/no pointer receiver in the Country struct methods. Also some memory improvements in subdivision struct --- country.go | 2 ++ subdivision.go | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/country.go b/country.go index 8a1abfc..8d7a2dc 100644 --- a/country.go +++ b/country.go @@ -32,6 +32,8 @@ type Country struct { } // MeasurableCoordinates provides long/lat for country struct +// it does not store a pointer receiver to Country, as it needs to implement the +// Measurer interface func (c Country) MeasurableCoordinates() (lat, long float64) { return c.Coordinates.Latitude, c.Coordinates.Longitude diff --git a/subdivision.go b/subdivision.go index 01871ef..e8303fb 100644 --- a/subdivision.go +++ b/subdivision.go @@ -12,7 +12,7 @@ type SubDivision struct { } // MeasurableCoordinates provides long/lat for country struct -func (sd SubDivision) MeasurableCoordinates() (lat, long float64) { +func (sd *SubDivision) MeasurableCoordinates() (lat, long float64) { return sd.Coordinates.Latitude, sd.Coordinates.Longitude