From 48e1aeb0674ba6899c7b06a79228a5817140b990 Mon Sep 17 00:00:00 2001 From: Paul Lecuq Date: Sat, 5 Dec 2020 18:36:39 +0100 Subject: [PATCH] minor changes on code --- src/database/main.go | 7 ++++++- src/qrz/main.go | 16 +++++++++++++--- src/qrzws/main.go | 3 ++- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/database/main.go b/src/database/main.go index 928b5aa..e5e92cb 100644 --- a/src/database/main.go +++ b/src/database/main.go @@ -13,7 +13,12 @@ import ( // Initialize creates connection to database and exec Schema func Initialize(config *config.Config) (err error) { - config.Db, err = xorm.NewEngine("postgres", fmt.Sprintf("postgres://%s:%s@%s/%s", config.DbUsername, config.DbPassword, config.DbHostname, config.DbName)) + config.Db, err = xorm.NewEngine("postgres", + fmt.Sprintf("postgres://%s:%s@%s/%s", + config.DbUsername, + config.DbPassword, + config.DbHostname, + config.DbName)) if err != nil { log.Fatalln(err) } diff --git a/src/qrz/main.go b/src/qrz/main.go index ddc985c..21a7ff6 100644 --- a/src/qrz/main.go +++ b/src/qrz/main.go @@ -53,7 +53,9 @@ func Run(config config.Config) (err error) { log.Println(err) } } else { - fmt.Println(fmt.Sprintf("No entry to insert in database for group %s", group)) + fmt.Println( + fmt.Sprintf("No entry to insert in database for group %s", + group)) } } return @@ -144,7 +146,9 @@ func insertFrsEntryToDB(config config.Config, frsPeople map[string]Qrz) (err err var qrzNum int - fmt.Println(fmt.Sprintf("Starting insert of %d entries", len(frsPeople))) + fmt.Println( + fmt.Sprintf("Starting insert of %d entries", + len(frsPeople))) for _, frs := range frsPeople { _, err = session.Insert(&frs) @@ -179,7 +183,13 @@ func insertFrsEntryToDB(config config.Config, frsPeople map[string]Qrz) (err err // ToSlice converts struct to array func ToSlice(qrz Qrz) (out []string) { - out = []string{qrz.QRZ, qrz.Name, qrz.City, qrz.Dept, qrz.Country, qrz.DMRID} + out = []string{ + qrz.QRZ, + qrz.Name, + qrz.City, + qrz.Dept, + qrz.Country, + qrz.DMRID} return } diff --git a/src/qrzws/main.go b/src/qrzws/main.go index 975c38e..334656a 100644 --- a/src/qrzws/main.go +++ b/src/qrzws/main.go @@ -134,7 +134,8 @@ func BuildQueryCountFiltered(config config.Config, qrzdt QrzDatatableInput) (cnt // BuildQueryCountTotal builds query for counting totals func BuildQueryCountTotal(config config.Config, qrzdt QrzDatatableInput) (cnt int64, err error) { - cnt, err = config.Db.SQL("SELECT COUNT(*) FROM qrz").Count() + var qrz qrz.Qrz + cnt, err = config.Db.Count(&qrz) return }