From 70372e58ab2e9e2d0f14a2c24568c3f2fb6d99cb Mon Sep 17 00:00:00 2001 From: ditatompel Date: Sat, 8 Jun 2024 00:53:28 +0700 Subject: [PATCH] Changed the initialization of the `countries` slice --- internal/monero/monero.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/internal/monero/monero.go b/internal/monero/monero.go index e7251b9..3bb28b4 100644 --- a/internal/monero/monero.go +++ b/internal/monero/monero.go @@ -329,15 +329,17 @@ func (r *MoneroRepo) NetFees() []NetFee { return netFees } +// Countries represents list of countries type Countries struct { TotalNodes int `json:"total_nodes" db:"total_nodes"` CC string `json:"cc" db:"country"` // country code Name string `json:"name" db:"country_name"` } +// Get list of countries (count by nodes) func (r *MoneroRepo) Countries() ([]Countries, error) { - countries := []Countries{} - err := r.db.Select(&countries, ` + var c []Countries + err := r.db.Select(&c, ` SELECT COUNT(id) AS total_nodes, country, @@ -348,5 +350,5 @@ func (r *MoneroRepo) Countries() ([]Countries, error) { country ORDER BY country ASC`) - return countries, err + return c, err }