From ad87dd53d83c11ececa40d98d9b76e5f39c5465e Mon Sep 17 00:00:00 2001 From: Piotr Biernat Date: Tue, 4 Apr 2023 01:01:13 +0200 Subject: [PATCH 1/2] Fixed staticcheck errors --- src/cmd/worker/main.go | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/cmd/worker/main.go b/src/cmd/worker/main.go index 8924267..e0f985a 100644 --- a/src/cmd/worker/main.go +++ b/src/cmd/worker/main.go @@ -25,17 +25,17 @@ import ( ) const ( - defAppName = "basket-worker" - defLoggerAddr = "api-logger:24224" - defRegistryAddr = "api-registry:8500" - defDbURL = "postgres://postgres:12345678@postgres-db:5432/egommerce" - defCacheAddr = "api-cache:6379" - defCachePassword = "12345678" - defMongoDbURL = "mongodb://mongodb:12345678@mongo-db:27017" - defEventBusURL = "amqp://guest:guest@api-eventbus:5672" - ebEventsExchange = "api-events" - ebEventsQueue = "basket-worker" - defKVNmspc = "dev.egommerce/service/basket-worker" +// defAppName = "basket-worker" +// defLoggerAddr = "api-logger:24224" +// defRegistryAddr = "api-registry:8500" +// defDbURL = "postgres://postgres:12345678@postgres-db:5432/egommerce" +// defCacheAddr = "api-cache:6379" +// defCachePassword = "12345678" +// defMongoDbURL = "mongodb://mongodb:12345678@mongo-db:27017" +// defEventBusURL = "amqp://guest:guest@api-eventbus:5672" +// ebEventsExchange = "api-events" +// ebEventsQueue = "basket-worker" +// defKVNmspc = "dev.egommerce/service/basket-worker" ) func main() { From 50ffd267f378cf530c96133185a40949c4503e79 Mon Sep 17 00:00:00 2001 From: Piotr Biernat Date: Tue, 4 Apr 2023 01:08:01 +0200 Subject: [PATCH 2/2] Fixed go vet errors --- src/cmd/worker/main.go | 4 ++-- src/pkg/server/server.go | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/cmd/worker/main.go b/src/cmd/worker/main.go index e0f985a..043b9d4 100644 --- a/src/cmd/worker/main.go +++ b/src/cmd/worker/main.go @@ -169,7 +169,7 @@ func main() { basket, err := ui.AddProductToBasket(basketSrv, productID, qty, basketID, reqID) if err == nil { - logger.Log("Product #%s added to basket #%s. ReqID: #%s", productID, basket.ID, reqID) + logger.Log("Product #%d added to basket #%s. ReqID: #%s", productID, basket.ID, reqID) } case strings.Contains(eName, event.EVENT_PRODUCT_REMOVED_FROM_BASKET): productID := int(data["product_id"].(float64)) @@ -177,7 +177,7 @@ func main() { basket, err := ui.RemoveProductFromBasket(basketSrv, productID, qty, basketID, reqID) if err == nil { - logger.Log("Product #%s removed from basket #%s. ReqID: #%s", productID, basket.ID, reqID) + logger.Log("Product #%d removed from basket #%s. ReqID: #%s", productID, basket.ID, reqID) } } diff --git a/src/pkg/server/server.go b/src/pkg/server/server.go index 10c7029..86bd22a 100644 --- a/src/pkg/server/server.go +++ b/src/pkg/server/server.go @@ -58,20 +58,20 @@ func (s *Server) GetRequestID(c *fiber.Ctx) (string, error) { // @Refactor make single func with error message and optional http status code... func (s *Server) Error400(c *fiber.Ctx, msg string) error { - return c.Status(fiber.StatusBadRequest).JSON(http.ErrorResponse{msg}) + return c.Status(fiber.StatusBadRequest).JSON(http.ErrorResponse{Error: msg}) // test with &(reference) before http.ErrorMessage, but probably it's gonna be erroneous } func (s *Server) Error401(c *fiber.Ctx, msg string) error { - return c.Status(fiber.StatusUnauthorized).JSON(http.ErrorResponse{msg}) + return c.Status(fiber.StatusUnauthorized).JSON(http.ErrorResponse{Error: msg}) } func (s *Server) Error403(c *fiber.Ctx, msg string) error { - return c.Status(fiber.StatusForbidden).JSON(http.ErrorResponse{msg}) + return c.Status(fiber.StatusForbidden).JSON(http.ErrorResponse{Error: msg}) } func (s *Server) Error404(c *fiber.Ctx, msg string) error { - return c.Status(fiber.StatusNotFound).JSON(http.ErrorResponse{msg}) + return c.Status(fiber.StatusNotFound).JSON(http.ErrorResponse{Error: msg}) } // @EndRefactor