From 73e8d3c14e9ce219977e911049083b73b048e727 Mon Sep 17 00:00:00 2001 From: Preetinder Singh Date: Sat, 15 Jun 2024 18:48:24 +0530 Subject: [PATCH 1/2] Solved go version workflow error --- .github/workflows/check-pull-requests.yml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/check-pull-requests.yml b/.github/workflows/check-pull-requests.yml index 182d216..58ad1a3 100644 --- a/.github/workflows/check-pull-requests.yml +++ b/.github/workflows/check-pull-requests.yml @@ -30,10 +30,11 @@ jobs: - name: Set up Go uses: actions/setup-go@v4 with: - go-version: 1.20 + go-version: 1.20.4 - name: Install dependencies - run: cd backend && go mod tidy + run: go mod tidy + working-directory: ./backend - name: Wait for Redis to be ready run: | @@ -45,7 +46,9 @@ jobs: # - name: Run tests # env: # REDIS_URL: redis://localhost:6379 - # run: cd backend && go test ./... + # run: go test ./... + # working-directory: ./backend - name: Build the project - run: cd backend && go build -v -o main main.go + run: go build -v -o main main.go + working-directory: ./backend From 5a3d7b296de49dbedaf993bc44ec95a9dea0ec67 Mon Sep 17 00:00:00 2001 From: Preetinder Singh Date: Sat, 15 Jun 2024 18:55:28 +0530 Subject: [PATCH 2/2] Solved router error --- backend/pkg/router/router.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/backend/pkg/router/router.go b/backend/pkg/router/router.go index 7161ffe..d64ac75 100644 --- a/backend/pkg/router/router.go +++ b/backend/pkg/router/router.go @@ -35,10 +35,10 @@ func GetAllLinks(w http.ResponseWriter, r *http.Request) { w.Write([]byte("No links found")) return } - err := json.NewEncoder(w).Encode(links) - if err != nil { - http.Error(w, err.Error(), http.StatusInternalServerError) - return + var linksData []string + for _, link := range links { + // w.Write([]byte(fmt.Sprintf("%s - %s\n", link.ShortURL, link.Link))) + linksData = append(linksData, fmt.Sprintf("%s - %s\n", link.ShortURL, link.Link)) } page.Execute(w, linksData) }