From ce3fc2d77d78ff6e7a2955266782fbf79ca1ad5c Mon Sep 17 00:00:00 2001 From: Gregory Oschwald Date: Mon, 11 Nov 2024 09:39:27 -0800 Subject: [PATCH] Don't mix receiver type --- client/download.go | 2 +- internal/geoipupdate/database/reader.go | 8 ++++++-- internal/geoipupdate/geoip_updater_test.go | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/client/download.go b/client/download.go index bc06972..6316db7 100644 --- a/client/download.go +++ b/client/download.go @@ -63,7 +63,7 @@ type DownloadResponse struct { // // Returns an [HTTPError] if the server returns a non-200 status code. This // can be used to identify problems with license. -func (c Client) Download( +func (c *Client) Download( ctx context.Context, editionID, md5 string, diff --git a/internal/geoipupdate/database/reader.go b/internal/geoipupdate/database/reader.go index b55ba76..c269a7b 100644 --- a/internal/geoipupdate/database/reader.go +++ b/internal/geoipupdate/database/reader.go @@ -23,14 +23,18 @@ type ReadResult struct { } // MarshalJSON is a custom json marshaler that strips out zero time fields. -func (r ReadResult) MarshalJSON() ([]byte, error) { +func (r *ReadResult) MarshalJSON() ([]byte, error) { + if r == nil { + return []byte("null"), nil + } + type partialResult ReadResult s := &struct { partialResult ModifiedAt int64 `json:"modified_at,omitempty"` CheckedAt int64 `json:"checked_at,omitempty"` }{ - partialResult: partialResult(r), + partialResult: partialResult(*r), ModifiedAt: 0, CheckedAt: 0, } diff --git a/internal/geoipupdate/geoip_updater_test.go b/internal/geoipupdate/geoip_updater_test.go index 44dfcf8..09784aa 100644 --- a/internal/geoipupdate/geoip_updater_test.go +++ b/internal/geoipupdate/geoip_updater_test.go @@ -283,7 +283,7 @@ func (w *mockWriter) Write( return nil } -func (w mockWriter) GetHash(editionID string) (string, error) { +func (w *mockWriter) GetHash(editionID string) (string, error) { return w.md5s[editionID], nil }