From 94fbc0d32e9e0580b765e48a584c7b912b0d2a67 Mon Sep 17 00:00:00 2001 From: Cakrawala <48281037+WahidinAji@users.noreply.github.com> Date: Wed, 11 May 2022 21:30:44 +0700 Subject: [PATCH 1/4] Update joke_total.go change to string(total) --- api/handler/joke/joke_total.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/handler/joke/joke_total.go b/api/handler/joke/joke_total.go index a820134..38299c1 100644 --- a/api/handler/joke/joke_total.go +++ b/api/handler/joke/joke_total.go @@ -38,6 +38,6 @@ func (d *Dependencies) TotalJokes(c *fiber.Ctx) error { return c. Status(fiber.StatusOK). JSON(ResponseJoke{ - Message: strconv.Itoa(int(total[0])), + Message: string(total), }) } From b56b8ab0ac4838c5aeb40a0aaabb71650f14d61f Mon Sep 17 00:00:00 2001 From: Cakrawala <48281037+WahidinAji@users.noreply.github.com> Date: Wed, 11 May 2022 21:35:14 +0700 Subject: [PATCH 2/4] Update setter.go convert int to string --- api/core/joke/setter.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/core/joke/setter.go b/api/core/joke/setter.go index c8ef51a..ddf4829 100644 --- a/api/core/joke/setter.go +++ b/api/core/joke/setter.go @@ -47,7 +47,7 @@ func SetTotalJoke(db *pgxpool.Pool, ctx context.Context, memory *bigcache.BigCac return err } - var total = []byte{byte(len(data))} + var total = []byte(strconv.Itoa(len(data))) err = memory.Set("total", total) if err != nil { return err From ac29cf1c6be37bd2db5993857b9fdd3d93b15b75 Mon Sep 17 00:00:00 2001 From: Cakrawala <48281037+WahidinAji@users.noreply.github.com> Date: Wed, 11 May 2022 21:47:53 +0700 Subject: [PATCH 3/4] Update setter.go lol, I forgot to import the strconv package in the last commit --- api/core/joke/setter.go | 1 + 1 file changed, 1 insertion(+) diff --git a/api/core/joke/setter.go b/api/core/joke/setter.go index ddf4829..335b29c 100644 --- a/api/core/joke/setter.go +++ b/api/core/joke/setter.go @@ -2,6 +2,7 @@ package joke import ( "context" + "strconv" "jokes-bapak2-api/core/schema" "github.com/Masterminds/squirrel" From 1fa40945d0a48171916527bd54f3c29f69f31562 Mon Sep 17 00:00:00 2001 From: Cakrawala <48281037+WahidinAji@users.noreply.github.com> Date: Wed, 11 May 2022 21:48:41 +0700 Subject: [PATCH 4/4] Update joke_total.go deleted strconv package is never used --- api/handler/joke/joke_total.go | 1 - 1 file changed, 1 deletion(-) diff --git a/api/handler/joke/joke_total.go b/api/handler/joke/joke_total.go index 38299c1..298114f 100644 --- a/api/handler/joke/joke_total.go +++ b/api/handler/joke/joke_total.go @@ -3,7 +3,6 @@ package joke import ( "errors" core "jokes-bapak2-api/core/joke" - "strconv" "github.com/allegro/bigcache/v3" "github.com/gofiber/fiber/v2"