From 07c48435f8f0a718be09dd1e0100fba21b28c466 Mon Sep 17 00:00:00 2001 From: AmanT776 Date: Wed, 12 Aug 2026 10:46:57 +0300 Subject: [PATCH 01/40] first push --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index c2bec0368b7..e35e869552b 100644 --- a/README.md +++ b/README.md @@ -21,3 +21,5 @@ go build -o notely && ./notely *This starts the server in non-database mode.* It will serve a simple webpage at `http://localhost:8080`. You do *not* need to set up a database or any interactivity on the webpage yet. Instructions for that will come later in the course! + +aman's version of Boot.dev's Notely app From 728e2269cc70cbd03b8765f1948eaf559b7d0296 Mon Sep 17 00:00:00 2001 From: AmanT776 Date: Wed, 12 Aug 2026 11:05:37 +0300 Subject: [PATCH 02/40] feat: add github workflows --- .github/workflows/ci.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000000..0d7015ee2cb --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,20 @@ +name: ci + +on: + pull_request: + branches: [main] +jobs: + tests: + name: Tests + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v6 + + - name: Set up Go + uses: actions/setup-go@v6 + with: + go-version: "1.26.0" + + - name: Force Failure + run: (exit1 1 From fdda726a63316e9a229270f7ef410a07db22919b Mon Sep 17 00:00:00 2001 From: AmanT776 Date: Wed, 12 Aug 2026 11:14:41 +0300 Subject: [PATCH 03/40] feat: change the last action to display go version --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0d7015ee2cb..d66d4ca0850 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,4 +17,4 @@ jobs: go-version: "1.26.0" - name: Force Failure - run: (exit1 1 + run: go --version From 4e56225801f945354a50da9916df6ae9727cdd01 Mon Sep 17 00:00:00 2001 From: AmanT776 Date: Wed, 12 Aug 2026 11:16:05 +0300 Subject: [PATCH 04/40] fix: update command to check Go version in CI workflow --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d66d4ca0850..d7fe1df17b2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,4 +17,4 @@ jobs: go-version: "1.26.0" - name: Force Failure - run: go --version + run: go version From 63d9304715c44ed6d578f45b1d56d3c2763a2416 Mon Sep 17 00:00:00 2001 From: AmanT776 Date: Wed, 12 Aug 2026 11:42:09 +0300 Subject: [PATCH 05/40] feat: wrote test for auth and added it on the ci delibrately broken auth code to test the ci --- internal/auth/auth.go | 2 +- internal/auth/get_api_key_test.go | 64 +++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 internal/auth/get_api_key_test.go diff --git a/internal/auth/auth.go b/internal/auth/auth.go index f969aacf638..674eaea4581 100644 --- a/internal/auth/auth.go +++ b/internal/auth/auth.go @@ -15,7 +15,7 @@ func GetAPIKey(headers http.Header) (string, error) { return "", ErrNoAuthHeaderIncluded } splitAuth := strings.Split(authHeader, " ") - if len(splitAuth) < 2 || splitAuth[0] != "ApiKey" { + if len(splitAuth) < 1 || splitAuth[0] != "ApiKey" { return "", errors.New("malformed authorization header") } diff --git a/internal/auth/get_api_key_test.go b/internal/auth/get_api_key_test.go new file mode 100644 index 00000000000..acab1544aab --- /dev/null +++ b/internal/auth/get_api_key_test.go @@ -0,0 +1,64 @@ +package auth_test + +import ( + "errors" + "net/http" + "testing" + + "github.com/bootdotdev/learn-cicd-starter/internal/auth" +) + +func testApiKey(t *testing.T){ + tests := []struct{ + name string + headers http.Header + expectedKey string + expectedError error + }{ + { + name: "successfull extraction with ApiKey scheme", + headers: http.Header{ + "Authorization":[]string{"ApiKey secret-token-123"}, + }, + expectedKey: "secret-token-123", + expectedError: nil, + }, + { + name: "malformed header - wrong scheme prefix", + headers: http.Header{ + "Authorization": []string{"Bearer secret-token-123"}, + }, + expectedKey: "", + expectedError: errors.New("malformed authorization header"), + }, + } + for _,tc := range tests{ + t.Run(tc.name, func (t * testing.T) { + key, err := auth.GetAPIKey(tc.headers) + + if tc.expectedError != nil { + if err == nil { + t.Fatalf("expected error %v, got nil", tc.expectedError) + } + + // Use errors.Is for sentinel errors, or string comparison for generic errors + if errors.Is(tc.expectedError, auth.ErrNoAuthHeaderIncluded) { + if !errors.Is(err, auth.ErrNoAuthHeaderIncluded) { + t.Errorf("expected sentinel error %v, got %v", tc.expectedError, err) + } + } else if err.Error() != tc.expectedError.Error() { + t.Errorf("expected error message %q, got %q", tc.expectedError.Error(), err.Error()) + } + } else { + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + } + + // 2. Handle key assertions + if key != tc.expectedKey { + t.Errorf("expected key %q, got %q", tc.expectedKey, key) + } + }) + } +} \ No newline at end of file From 9ca0fd8c857f3eb395f9a91693de8e91bb07d7e1 Mon Sep 17 00:00:00 2001 From: AmanT776 Date: Wed, 12 Aug 2026 11:43:46 +0300 Subject: [PATCH 06/40] feat:- added test step --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d7fe1df17b2..cf51545fe8e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,4 +17,4 @@ jobs: go-version: "1.26.0" - name: Force Failure - run: go version + run: go test ./... From bed2d12660fc6c044e67e043cf0a48724983da97 Mon Sep 17 00:00:00 2001 From: AmanT776 Date: Wed, 12 Aug 2026 11:45:27 +0300 Subject: [PATCH 07/40] fix: update authorization header validation in GetAPIKey function --- internal/auth/auth.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/auth/auth.go b/internal/auth/auth.go index 674eaea4581..20ef43c9454 100644 --- a/internal/auth/auth.go +++ b/internal/auth/auth.go @@ -15,7 +15,7 @@ func GetAPIKey(headers http.Header) (string, error) { return "", ErrNoAuthHeaderIncluded } splitAuth := strings.Split(authHeader, " ") - if len(splitAuth) < 1 || splitAuth[0] != "ApiKey" { + if len(splitAuth) < 2 || splitAuth[0] != "bearer" { return "", errors.New("malformed authorization header") } From 25ee06711d9cde59e9283f744fe92d6264bd29fa Mon Sep 17 00:00:00 2001 From: AmanT776 Date: Wed, 12 Aug 2026 11:48:46 +0300 Subject: [PATCH 08/40] fix: rename test function to follow Go naming conventions --- internal/auth/get_api_key_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/auth/get_api_key_test.go b/internal/auth/get_api_key_test.go index acab1544aab..d6ec207153d 100644 --- a/internal/auth/get_api_key_test.go +++ b/internal/auth/get_api_key_test.go @@ -8,7 +8,7 @@ import ( "github.com/bootdotdev/learn-cicd-starter/internal/auth" ) -func testApiKey(t *testing.T){ +func TestApiKey(t *testing.T){ tests := []struct{ name string headers http.Header From 99783c850724a096fcd93bfe400820a6e87b5288 Mon Sep 17 00:00:00 2001 From: AmanT776 Date: Wed, 12 Aug 2026 11:50:13 +0300 Subject: [PATCH 09/40] fix: update authorization header type check in GetAPIKey function --- internal/auth/auth.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/auth/auth.go b/internal/auth/auth.go index 20ef43c9454..f969aacf638 100644 --- a/internal/auth/auth.go +++ b/internal/auth/auth.go @@ -15,7 +15,7 @@ func GetAPIKey(headers http.Header) (string, error) { return "", ErrNoAuthHeaderIncluded } splitAuth := strings.Split(authHeader, " ") - if len(splitAuth) < 2 || splitAuth[0] != "bearer" { + if len(splitAuth) < 2 || splitAuth[0] != "ApiKey" { return "", errors.New("malformed authorization header") } From 9de09d6c4fd82eefc4f68f7cff12fc0d99c67736 Mon Sep 17 00:00:00 2001 From: AmanT776 Date: Wed, 12 Aug 2026 12:01:58 +0300 Subject: [PATCH 10/40] fix: add coverage flag to go test command in CI workflow --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cf51545fe8e..1fe2e74baf3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,4 +17,4 @@ jobs: go-version: "1.26.0" - name: Force Failure - run: go test ./... + run: go test ./... -cover From 5d50d4a731042fa791c7f596b2f1e79f32c981d6 Mon Sep 17 00:00:00 2001 From: AmanT776 Date: Wed, 12 Aug 2026 12:05:11 +0300 Subject: [PATCH 11/40] fix: update formatting in README for clarity --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e35e869552b..53829a6b828 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +![alt text goes here](https://github.com///actions/workflows//badge.svg) + # learn-cicd-starter (Notely) This repo contains the starter code for the "Notely" application for the "Learn CICD" course on [Boot.dev](https://boot.dev). @@ -18,8 +20,8 @@ Run the server: go build -o notely && ./notely ``` -*This starts the server in non-database mode.* It will serve a simple webpage at `http://localhost:8080`. +_This starts the server in non-database mode._ It will serve a simple webpage at `http://localhost:8080`. -You do *not* need to set up a database or any interactivity on the webpage yet. Instructions for that will come later in the course! +You do _not_ need to set up a database or any interactivity on the webpage yet. Instructions for that will come later in the course! aman's version of Boot.dev's Notely app From 88da9858c8dabf12a9a5706885fbf8beaf99b933 Mon Sep 17 00:00:00 2001 From: AmanT776 Date: Wed, 12 Aug 2026 12:08:55 +0300 Subject: [PATCH 12/40] fix: update test badge link in README for accuracy --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 53829a6b828..0496df3a3b5 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -![alt text goes here](https://github.com///actions/workflows//badge.svg) +![test badge]("https://github.com///actions/workflows/<.github/workflows/ci.yml>/badge.svg") # learn-cicd-starter (Notely) From 068c864c4b15488ff6c6daae8b3cbace3d0214fc Mon Sep 17 00:00:00 2001 From: AmanT776 Date: Wed, 12 Aug 2026 12:12:24 +0300 Subject: [PATCH 13/40] fix: correct test badge link in README for accuracy --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0496df3a3b5..2770c01ffb1 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -![test badge]("https://github.com///actions/workflows/<.github/workflows/ci.yml>/badge.svg") +[![test badge](https://github.com/AmanT776/learn-cicd-starter/actions/workflows/ci.yml/badge.svg)](https://github.com/AmanT776/learn-cicd-starter/actions/workflows/ci.yml) # learn-cicd-starter (Notely) From e4761d0ddcb5e7d3f74766d5edf529f3137d7f27 Mon Sep 17 00:00:00 2001 From: AmanT776 Date: Wed, 12 Aug 2026 19:21:47 +0300 Subject: [PATCH 14/40] fix: add lint and format job to CI workflow --- .github/workflows/ci.yml | 14 ++++++++++++++ internal/auth/get_api_key_test.go | 26 ++++++++++++-------------- 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1fe2e74baf3..d7df398d909 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,3 +18,17 @@ jobs: - name: Force Failure run: go test ./... -cover +jobs: + lint-and-format: + runs-on: ubuntu-latest + + steps: + - name: Check out code + - uses: actions/checkout@v6 + + - name: Set up Go + - uses: actions/setup-go@v6 + with: + go-version: "1.26.0" + - name: format code + run: test -z $(go fmt ./..) \ No newline at end of file diff --git a/internal/auth/get_api_key_test.go b/internal/auth/get_api_key_test.go index d6ec207153d..5205c67e559 100644 --- a/internal/auth/get_api_key_test.go +++ b/internal/auth/get_api_key_test.go @@ -8,19 +8,19 @@ import ( "github.com/bootdotdev/learn-cicd-starter/internal/auth" ) -func TestApiKey(t *testing.T){ - tests := []struct{ - name string - headers http.Header - expectedKey string +func TestApiKey(t *testing.T) { + tests := []struct { + name string + headers http.Header + expectedKey string expectedError error }{ { name: "successfull extraction with ApiKey scheme", headers: http.Header{ - "Authorization":[]string{"ApiKey secret-token-123"}, + "Authorization": []string{"ApiKey secret-token-123"}, }, - expectedKey: "secret-token-123", + expectedKey: "secret-token-123", expectedError: nil, }, { @@ -28,19 +28,19 @@ func TestApiKey(t *testing.T){ headers: http.Header{ "Authorization": []string{"Bearer secret-token-123"}, }, - expectedKey: "", + expectedKey: "", expectedError: errors.New("malformed authorization header"), }, } - for _,tc := range tests{ - t.Run(tc.name, func (t * testing.T) { + for _, tc := range tests { + t.Run(tc.name, func(t *testing.T) { key, err := auth.GetAPIKey(tc.headers) if tc.expectedError != nil { if err == nil { t.Fatalf("expected error %v, got nil", tc.expectedError) } - + // Use errors.Is for sentinel errors, or string comparison for generic errors if errors.Is(tc.expectedError, auth.ErrNoAuthHeaderIncluded) { if !errors.Is(err, auth.ErrNoAuthHeaderIncluded) { @@ -59,6 +59,4 @@ func TestApiKey(t *testing.T){ if key != tc.expectedKey { t.Errorf("expected key %q, got %q", tc.expectedKey, key) } - }) - } -} \ No newline at end of file + })}} From 04710753dc6eaedd82a98e7fd6b23e60167261d1 Mon Sep 17 00:00:00 2001 From: AmanT776 Date: Thu, 13 Aug 2026 09:32:17 +0300 Subject: [PATCH 15/40] fix: format CI workflow for consistency and clarity --- .github/workflows/ci.yml | 50 ++++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d7df398d909..b53c75aecf0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,32 +3,32 @@ name: ci on: pull_request: branches: [main] -jobs: - tests: - name: Tests - runs-on: ubuntu-latest - steps: - - name: Check out code - uses: actions/checkout@v6 + jobs: + tests: + name: Tests + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v6 - - name: Set up Go - uses: actions/setup-go@v6 - with: - go-version: "1.26.0" + - name: Set up Go + uses: actions/setup-go@v6 + with: + go-version: "1.26.0" - - name: Force Failure - run: go test ./... -cover -jobs: - lint-and-format: - runs-on: ubuntu-latest + - name: Force Failure + run: go test ./... -cover + jobs: + lint-and-format: + runs-on: ubuntu-latest - steps: - - name: Check out code - - uses: actions/checkout@v6 + steps: + - name: Check out code + - uses: actions/checkout@v6 - - name: Set up Go - - uses: actions/setup-go@v6 - with: - go-version: "1.26.0" - - name: format code - run: test -z $(go fmt ./..) \ No newline at end of file + - name: Set up Go + - uses: actions/setup-go@v6 + with: + go-version: "1.26.0" + - name: format code + run: test -z $(go fmt ./..) \ No newline at end of file From bbd28b03f70535850f6803f32131c27817e2fdc9 Mon Sep 17 00:00:00 2001 From: AmanT776 Date: Thu, 13 Aug 2026 09:34:59 +0300 Subject: [PATCH 16/40] fix: improve formatting and structure of CI workflow --- .github/workflows/ci.yml | 52 +++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 25 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b53c75aecf0..1982daf3a52 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,32 +3,34 @@ name: ci on: pull_request: branches: [main] - jobs: - tests: - name: Tests - runs-on: ubuntu-latest - steps: - - name: Check out code - uses: actions/checkout@v6 - - name: Set up Go - uses: actions/setup-go@v6 - with: - go-version: "1.26.0" +jobs: + tests: + name: Tests + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v6 - - name: Force Failure - run: go test ./... -cover - jobs: - lint-and-format: - runs-on: ubuntu-latest + - name: Set up Go + uses: actions/setup-go@v6 + with: + go-version: "1.26.0" - steps: - - name: Check out code - - uses: actions/checkout@v6 + - name: Force Failure + run: go test ./... -cover - - name: Set up Go - - uses: actions/setup-go@v6 - with: - go-version: "1.26.0" - - name: format code - run: test -z $(go fmt ./..) \ No newline at end of file + lint-and-format: + name: Lint and Format + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v6 + + - name: Set up Go + uses: actions/setup-go@v6 + with: + go-version: "1.26.0" + + - name: Format code + run: test -z "$(go fmt ./...)" From 92a5484577f098b388d99c8c02102f43a04f9392 Mon Sep 17 00:00:00 2001 From: AmanT776 Date: Thu, 13 Aug 2026 09:38:19 +0300 Subject: [PATCH 17/40] fix: correct test function closure in GetAPIKey test --- internal/auth/get_api_key_test.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/auth/get_api_key_test.go b/internal/auth/get_api_key_test.go index 5205c67e559..e2892aa7497 100644 --- a/internal/auth/get_api_key_test.go +++ b/internal/auth/get_api_key_test.go @@ -59,4 +59,6 @@ func TestApiKey(t *testing.T) { if key != tc.expectedKey { t.Errorf("expected key %q, got %q", tc.expectedKey, key) } - })}} + }) + } +} From 0bd3ee18ca242968a4de18fc07f9248b598a3a7c Mon Sep 17 00:00:00 2001 From: AmanT776 Date: Thu, 13 Aug 2026 09:41:34 +0300 Subject: [PATCH 18/40] fix: rename lint-and-format job to Style for clarity --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1982daf3a52..d6ac615d256 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,7 +21,7 @@ jobs: run: go test ./... -cover lint-and-format: - name: Lint and Format + name: Style runs-on: ubuntu-latest steps: - name: Check out code From aa039995cab766d133578b98438b15d95d568e39 Mon Sep 17 00:00:00 2001 From: AmanT776 Date: Thu, 13 Aug 2026 09:54:54 +0300 Subject: [PATCH 19/40] fix: add staticcheck installation and linting check to CI workflow --- .github/workflows/ci.yml | 4 ++++ main.go | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d6ac615d256..a0ffe88e6f3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,6 +31,10 @@ jobs: uses: actions/setup-go@v6 with: go-version: "1.26.0" + - name: Install staticcheck + run: go install go install honnef.co/go/tools/cmd/staticcheck@latest - name: Format code run: test -z "$(go fmt ./...)" + - name: check linting + run: staticcheck ./... diff --git a/main.go b/main.go index 19d7366c5f7..5ae2a9e68b7 100644 --- a/main.go +++ b/main.go @@ -24,6 +24,10 @@ type apiConfig struct { //go:embed static/* var staticFiles embed.FS +func unused(){ + +} + func main() { err := godotenv.Load(".env") if err != nil { From 0a875bcea04fec5a01eec44c9343eb7a0abe8bf1 Mon Sep 17 00:00:00 2001 From: AmanT776 Date: Thu, 13 Aug 2026 09:56:59 +0300 Subject: [PATCH 20/40] fix: update staticcheck installation to specific version 1.26.0 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a0ffe88e6f3..58803ebe49a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,7 +32,7 @@ jobs: with: go-version: "1.26.0" - name: Install staticcheck - run: go install go install honnef.co/go/tools/cmd/staticcheck@latest + run: go install go install honnef.co/go/tools/cmd/staticcheck@1.26.0 - name: Format code run: test -z "$(go fmt ./...)" From 361e2b65ecbd710c6d9081aa849a5d18754d8298 Mon Sep 17 00:00:00 2001 From: AmanT776 Date: Thu, 13 Aug 2026 09:59:19 +0300 Subject: [PATCH 21/40] fix: update staticcheck installation to version 0.7.0 --- .github/workflows/ci.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 58803ebe49a..a228eb5a68d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,8 +32,7 @@ jobs: with: go-version: "1.26.0" - name: Install staticcheck - run: go install go install honnef.co/go/tools/cmd/staticcheck@1.26.0 - + run: go install honnef.co/go/tools/cmd/staticcheck@v0.7.0 - name: Format code run: test -z "$(go fmt ./...)" - name: check linting From 1ac986e841defc3c9fbda8517304615e29269d47 Mon Sep 17 00:00:00 2001 From: AmanT776 Date: Thu, 13 Aug 2026 10:00:45 +0300 Subject: [PATCH 22/40] fix: format unused function for consistency --- main.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 5ae2a9e68b7..810577685d1 100644 --- a/main.go +++ b/main.go @@ -24,8 +24,8 @@ type apiConfig struct { //go:embed static/* var staticFiles embed.FS -func unused(){ - +func unused() { + } func main() { From da8c4c90105a64086320ae94bf118502dc876b3a Mon Sep 17 00:00:00 2001 From: AmanT776 Date: Thu, 13 Aug 2026 10:02:18 +0300 Subject: [PATCH 23/40] fix: remove unused function to improve code clarity --- main.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/main.go b/main.go index 810577685d1..4fcfcd6fb41 100644 --- a/main.go +++ b/main.go @@ -24,9 +24,6 @@ type apiConfig struct { //go:embed static/* var staticFiles embed.FS -func unused() { - -} func main() { err := godotenv.Load(".env") From e5b399dee39f9f641cde64340cd113c2768d8bca Mon Sep 17 00:00:00 2001 From: AmanT776 Date: Thu, 13 Aug 2026 10:03:53 +0300 Subject: [PATCH 24/40] fix: remove unnecessary blank line for improved readability --- main.go | 1 - 1 file changed, 1 deletion(-) diff --git a/main.go b/main.go index 4fcfcd6fb41..19d7366c5f7 100644 --- a/main.go +++ b/main.go @@ -24,7 +24,6 @@ type apiConfig struct { //go:embed static/* var staticFiles embed.FS - func main() { err := godotenv.Load(".env") if err != nil { From f467f0a8fb55dbb5ccffcc2d4c4c3fc942073bba Mon Sep 17 00:00:00 2001 From: AmanT776 Date: Thu, 13 Aug 2026 10:20:01 +0300 Subject: [PATCH 25/40] fix: add security tests with gosec installation and execution --- .github/workflows/ci.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a228eb5a68d..51b941060b8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,7 +19,15 @@ jobs: - name: Force Failure run: go test ./... -cover + security: + name: Scurity Tests + runs-on: ubuntu-latest + steps: + name: Install gosec + run: go install github.com/securego/gosec/v2/cmd/gosec@lates + name: check security + run: gosec ./... lint-and-format: name: Style runs-on: ubuntu-latest From 4a43e0260bbffa9a0bcd38c9844674f6c3d0c044 Mon Sep 17 00:00:00 2001 From: AmanT776 Date: Thu, 13 Aug 2026 10:21:39 +0300 Subject: [PATCH 26/40] fix: rename security job to security-scans for consistency --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 51b941060b8..ef388ff92a1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,7 +19,7 @@ jobs: - name: Force Failure run: go test ./... -cover - security: + security-scans: name: Scurity Tests runs-on: ubuntu-latest steps: From 7b56ed103809ead746c69c3f87b8a6a2901b0dbc Mon Sep 17 00:00:00 2001 From: AmanT776 Date: Thu, 13 Aug 2026 10:23:17 +0300 Subject: [PATCH 27/40] fix: format security job steps for consistency --- .github/workflows/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ef388ff92a1..51e6a7695c1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,11 +23,11 @@ jobs: name: Scurity Tests runs-on: ubuntu-latest steps: - name: Install gosec - run: go install github.com/securego/gosec/v2/cmd/gosec@lates + - name: Install gosec + run: go install github.com/securego/gosec/v2/cmd/gosec@lates - name: check security - run: gosec ./... + - name: check security + run: gosec ./... lint-and-format: name: Style runs-on: ubuntu-latest From bfc7eb8f100bbe50f64d8f9f6acd5c40f6756c59 Mon Sep 17 00:00:00 2001 From: AmanT776 Date: Thu, 13 Aug 2026 10:24:31 +0300 Subject: [PATCH 28/40] fix: correct typo in gosec installation command --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 51e6a7695c1..396cd793d94 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,7 +24,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Install gosec - run: go install github.com/securego/gosec/v2/cmd/gosec@lates + run: go install github.com/securego/gosec/v2/cmd/gosec@latest - name: check security run: gosec ./... From 28d6acd58641599514ff9e2e65b1bd81fdd7900b Mon Sep 17 00:00:00 2001 From: AmanT776 Date: Thu, 13 Aug 2026 10:28:56 +0300 Subject: [PATCH 29/40] fix: streamline Gosec security scanner setup in CI workflow --- .github/workflows/ci.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 396cd793d94..4726fc0949e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,11 +23,10 @@ jobs: name: Scurity Tests runs-on: ubuntu-latest steps: - - name: Install gosec - run: go install github.com/securego/gosec/v2/cmd/gosec@latest - - - name: check security - run: gosec ./... + - name: Run Gosec Security Scanner + uses: securego/gosec@master + with: + args: ./... lint-and-format: name: Style runs-on: ubuntu-latest From 96d239534ba67c5ad0748c53a073dda8403c1f80 Mon Sep 17 00:00:00 2001 From: AmanT776 Date: Thu, 13 Aug 2026 10:33:26 +0300 Subject: [PATCH 30/40] fix: update Gosec scanner args to include vendor module --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4726fc0949e..f38988fab6c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,7 +26,7 @@ jobs: - name: Run Gosec Security Scanner uses: securego/gosec@master with: - args: ./... + args: -mod=vendor ./... lint-and-format: name: Style runs-on: ubuntu-latest From 08d569cd83e6a2decc38f201c6190feec296e241 Mon Sep 17 00:00:00 2001 From: AmanT776 Date: Thu, 13 Aug 2026 10:34:55 +0300 Subject: [PATCH 31/40] fix: update Gosec scanner args to remove vendor module specification --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f38988fab6c..4726fc0949e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,7 +26,7 @@ jobs: - name: Run Gosec Security Scanner uses: securego/gosec@master with: - args: -mod=vendor ./... + args: ./... lint-and-format: name: Style runs-on: ubuntu-latest From 0956e457cb787b7f2c5417e08b7ec09a382a0be4 Mon Sep 17 00:00:00 2001 From: AmanT776 Date: Thu, 13 Aug 2026 10:36:06 +0300 Subject: [PATCH 32/40] fix: improve CI workflow by correcting job names and adding missing steps --- .github/workflows/ci.yml | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4726fc0949e..968dcfb788f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,6 +8,7 @@ jobs: tests: name: Tests runs-on: ubuntu-latest + steps: - name: Check out code uses: actions/checkout@v6 @@ -17,19 +18,26 @@ jobs: with: go-version: "1.26.0" - - name: Force Failure + - name: Run tests run: go test ./... -cover + security-scans: - name: Scurity Tests + name: Security Tests runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v6 + - name: Run Gosec Security Scanner uses: securego/gosec@master with: args: ./... + lint-and-format: name: Style runs-on: ubuntu-latest + steps: - name: Check out code uses: actions/checkout@v6 @@ -38,9 +46,12 @@ jobs: uses: actions/setup-go@v6 with: go-version: "1.26.0" + - name: Install staticcheck run: go install honnef.co/go/tools/cmd/staticcheck@v0.7.0 + - name: Format code run: test -z "$(go fmt ./...)" - - name: check linting + + - name: Check linting run: staticcheck ./... From b8d2b6879da6ec0601bc628ffc57d8ac423b723b Mon Sep 17 00:00:00 2001 From: AmanT776 Date: Thu, 13 Aug 2026 10:44:40 +0300 Subject: [PATCH 33/40] fix: enhance logging setup and improve server startup message --- main.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index 19d7366c5f7..8af883330af 100644 --- a/main.go +++ b/main.go @@ -3,10 +3,13 @@ package main import ( "database/sql" "embed" + "fmt" "io" "log" + "log/slog" "net/http" "os" + "time" "github.com/go-chi/chi" "github.com/go-chi/cors" @@ -25,6 +28,9 @@ type apiConfig struct { var staticFiles embed.FS func main() { + logger := slog.New(slog.NewTextHandler(os.Stderr, &slog.HandlerOptions{ + Level: slog.LevelInfo, + })) err := godotenv.Load(".env") if err != nil { log.Printf("warning: assuming default configuration. .env unreadable: %v", err) @@ -89,10 +95,11 @@ func main() { router.Mount("/v1", v1Router) srv := &http.Server{ - Addr: ":" + port, - Handler: router, + Addr: ":" + port, + Handler: router, + ReadHeaderTimeout: 3 * time.Second, } - log.Printf("Serving on port: %s\n", port) + logger.Info(fmt.Sprintf("Serving on port: %s\n", port)) log.Fatal(srv.ListenAndServe()) } From d71cb1b87524db2f341fffd72359dba13e581fe2 Mon Sep 17 00:00:00 2001 From: AmanT776 Date: Thu, 13 Aug 2026 10:48:32 +0300 Subject: [PATCH 34/40] fix: handle error when writing JSON response --- json.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/json.go b/json.go index 1e6e7985e18..767afa4931b 100644 --- a/json.go +++ b/json.go @@ -30,5 +30,7 @@ func respondWithJSON(w http.ResponseWriter, code int, payload interface{}) { return } w.WriteHeader(code) - w.Write(dat) + if _ , err := w.Write(dat) ; err != nil{ + log.Println(err) + } } From 2e7edca5b120099823bd98e0acfb8887ed2d64a2 Mon Sep 17 00:00:00 2001 From: AmanT776 Date: Thu, 13 Aug 2026 10:49:58 +0300 Subject: [PATCH 35/40] fix: correct formatting in respondWithJSON function --- json.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/json.go b/json.go index 767afa4931b..f9d0b6e1eb5 100644 --- a/json.go +++ b/json.go @@ -30,7 +30,7 @@ func respondWithJSON(w http.ResponseWriter, code int, payload interface{}) { return } w.WriteHeader(code) - if _ , err := w.Write(dat) ; err != nil{ + if _, err := w.Write(dat); err != nil { log.Println(err) } } From 3a4fd590d6935caec81f0e567abac5ad09ab8248 Mon Sep 17 00:00:00 2001 From: AmanT776 Date: Thu, 13 Aug 2026 10:51:42 +0300 Subject: [PATCH 36/40] fix: rename security scan job to align with naming conventions --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 968dcfb788f..d7d27ecf50e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,7 +22,7 @@ jobs: run: go test ./... -cover security-scans: - name: Security Tests + name: Tests runs-on: ubuntu-latest steps: From 91c1144dabcf283b4df50ceee22d8a8ccffaa806 Mon Sep 17 00:00:00 2001 From: AmanT776 Date: Fri, 14 Aug 2026 08:48:16 +0300 Subject: [PATCH 37/40] feat: add continuous deployment workflow for main branch --- .github/workflows/cd.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 .github/workflows/cd.yml diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml new file mode 100644 index 00000000000..fee547e8597 --- /dev/null +++ b/.github/workflows/cd.yml @@ -0,0 +1,16 @@ +name: cd +on: + push: + branches: [main] + jobs: + build-and-deploy: + - name: Deploy + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v6 + - name: Setup go + uses: actions/setup-go@v6 + - name: Build app + run: ./scripts/buildprod.sh From bfb7758f4dab2e3b8573e2c4a63d93d2997f0c2f Mon Sep 17 00:00:00 2001 From: AmanT776 Date: Fri, 14 Aug 2026 08:51:08 +0300 Subject: [PATCH 38/40] fix: update deployment workflow to correct job structure and maintain consistency --- .github/workflows/cd.yml | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index fee547e8597..22003dd015d 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -1,16 +1,24 @@ name: cd + on: push: branches: [main] - jobs: - build-and-deploy: - - name: Deploy - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v6 - - name: Setup go - uses: actions/setup-go@v6 - - name: Build app - run: ./scripts/buildprod.sh +jobs: + build-and-deploy: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version: "1.26.0" + + - name: Make script executable + run: chmod +x ./scripts/buildprod.sh + + - name: Build app + run: ./scripts/buildprod.sh From 59822fb8fc5dcde7306c17a2ab6f6273f7fb2e66 Mon Sep 17 00:00:00 2001 From: AmanT776 Date: Fri, 14 Aug 2026 08:55:33 +0300 Subject: [PATCH 39/40] fix: add job name to deployment workflow for clarity --- .github/workflows/cd.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 22003dd015d..331e9f7dea9 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -6,6 +6,7 @@ on: jobs: build-and-deploy: + name: Deploy runs-on: ubuntu-latest steps: From af80b32c84229102a7fc52d3a0a986d808da2adf Mon Sep 17 00:00:00 2001 From: AmanT776 Date: Fri, 14 Aug 2026 09:03:17 +0300 Subject: [PATCH 40/40] fix: correct job name for security scans in CI workflow --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d7d27ecf50e..16f4d799a47 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,7 +22,7 @@ jobs: run: go test ./... -cover security-scans: - name: Tests + name: Secuirty Tests runs-on: ubuntu-latest steps: