From 66c2de22ed9660175f8195796dfe2052a42287ed Mon Sep 17 00:00:00 2001 From: Crumb Owl Date: Wed, 2 Jul 2025 22:59:01 +0200 Subject: [PATCH] ProductBarcode: Go Linter fixing --- .../api/handlers/v1/v1_ctrl_product_search.go | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/backend/app/api/handlers/v1/v1_ctrl_product_search.go b/backend/app/api/handlers/v1/v1_ctrl_product_search.go index c245a779..24d9aefb 100644 --- a/backend/app/api/handlers/v1/v1_ctrl_product_search.go +++ b/backend/app/api/handlers/v1/v1_ctrl_product_search.go @@ -131,12 +131,12 @@ func (ctrl *V1Controller) HandleProductSearchFromEAN(conf config.BarcodeAPIConf) return nil, err } - //We Read the response body on the line below. + // We Read the response body on the line below. body, err := io.ReadAll(resp.Body) if err != nil { return nil, err } - //Convert the body to type string + // Convert the body to type string sb := string(body) log.Info().Msg("Response: " + sb) @@ -173,7 +173,6 @@ func (ctrl *V1Controller) HandleProductSearchFromEAN(conf config.BarcodeAPIConf) // Barcode spider implementation barcodespider := func(tokenAPI string, iEan string) ([]repo.BarcodeProduct, error) { - if len(tokenAPI) == 0 { return nil, errors.New("no api token configured for barcodespider") } @@ -194,12 +193,12 @@ func (ctrl *V1Controller) HandleProductSearchFromEAN(conf config.BarcodeAPIConf) return nil, err } - //We Read the response body on the line below. + // We Read the response body on the line below. body, err := io.ReadAll(resp.Body) if err != nil { return nil, err } - //Convert the body to type string + // Convert the body to type string sb := string(body) log.Info().Msg("Response: " + sb) @@ -208,7 +207,7 @@ func (ctrl *V1Controller) HandleProductSearchFromEAN(conf config.BarcodeAPIConf) log.Error().Msg("Can not unmarshal JSON") } - // TODO: check 200 code on HTTP repsonse. + // TODO: check 200 code on HTTP response. var p repo.BarcodeProduct p.Barcode = iEan p.SearchEngineName = "barcodespider.com" @@ -230,13 +229,9 @@ func (ctrl *V1Controller) HandleProductSearchFromEAN(conf config.BarcodeAPIConf) } // Merge everything. - for i := range ps { - products = append(products, ps[i]) - } + products = append(products, ps...) - for i := range ps2 { - products = append(products, ps2[i]) - } + products = append(products, ps2...) // Retrieve images if possible for i := range products {