From de1c7a8925cf7910bbf866b2b5ada82a09b6cd8f Mon Sep 17 00:00:00 2001 From: FluxCapacitor2 <31071265+FluxCapacitor2@users.noreply.github.com> Date: Sun, 21 Jul 2024 01:16:01 -0400 Subject: [PATCH] Fix `gofmt` pre-commit hook --- app/server/pagination_test.go | 56 +++++++++++++++++------------------ app/server/server.go | 2 +- package.json | 2 +- 3 files changed, 30 insertions(+), 30 deletions(-) diff --git a/app/server/pagination_test.go b/app/server/pagination_test.go index 5bd5e7d..6f6568d 100644 --- a/app/server/pagination_test.go +++ b/app/server/pagination_test.go @@ -40,38 +40,38 @@ func TestPagination(t *testing.T) { // Cursor in the middle of the results {page: 5, pageCount: 20, want: []resultsPage{ - {Number:"«", Current:false, URL:"http://localhost:8080/?page=1&q=hello&source=test"}, - {Number:"←" ,Current:false, URL:"http://localhost:8080/?page=4&q=hello&source=test"}, - {Number:"1" ,Current:false, URL:"http://localhost:8080/?page=1&q=hello&source=test"}, - {Number:"2" ,Current:false, URL:"http://localhost:8080/?page=2&q=hello&source=test"}, - {Number:"3" ,Current:false, URL:"http://localhost:8080/?page=3&q=hello&source=test"}, - {Number:"4" ,Current:false, URL:"http://localhost:8080/?page=4&q=hello&source=test"}, - {Number:"5" ,Current:true, URL:"http://localhost:8080/?page=5&q=hello&source=test"}, - {Number:"6" ,Current:false, URL:"http://localhost:8080/?page=6&q=hello&source=test"}, - {Number:"7" ,Current:false, URL:"http://localhost:8080/?page=7&q=hello&source=test"}, - {Number:"8" ,Current:false, URL:"http://localhost:8080/?page=8&q=hello&source=test"}, - {Number:"9" ,Current:false, URL:"http://localhost:8080/?page=9&q=hello&source=test"}, - {Number:"10", Current:false, URL:"http://localhost:8080/?page=10&q=hello&source=test"}, - {Number:"→" ,Current:false, URL:"http://localhost:8080/?page=6&q=hello&source=test"}, - {Number:"»" ,Current:false, URL:"http://localhost:8080/?page=20&q=hello&source=test"}, + {Number: "«", Current: false, URL: "http://localhost:8080/?page=1&q=hello&source=test"}, + {Number: "←", Current: false, URL: "http://localhost:8080/?page=4&q=hello&source=test"}, + {Number: "1", Current: false, URL: "http://localhost:8080/?page=1&q=hello&source=test"}, + {Number: "2", Current: false, URL: "http://localhost:8080/?page=2&q=hello&source=test"}, + {Number: "3", Current: false, URL: "http://localhost:8080/?page=3&q=hello&source=test"}, + {Number: "4", Current: false, URL: "http://localhost:8080/?page=4&q=hello&source=test"}, + {Number: "5", Current: true, URL: "http://localhost:8080/?page=5&q=hello&source=test"}, + {Number: "6", Current: false, URL: "http://localhost:8080/?page=6&q=hello&source=test"}, + {Number: "7", Current: false, URL: "http://localhost:8080/?page=7&q=hello&source=test"}, + {Number: "8", Current: false, URL: "http://localhost:8080/?page=8&q=hello&source=test"}, + {Number: "9", Current: false, URL: "http://localhost:8080/?page=9&q=hello&source=test"}, + {Number: "10", Current: false, URL: "http://localhost:8080/?page=10&q=hello&source=test"}, + {Number: "→", Current: false, URL: "http://localhost:8080/?page=6&q=hello&source=test"}, + {Number: "»", Current: false, URL: "http://localhost:8080/?page=20&q=hello&source=test"}, }}, // Cursor at the end {page: 20, pageCount: 20, want: []resultsPage{ - {Number:"«", Current:false, URL:"http://localhost:8080/?page=1&q=hello&source=test"}, - {Number:"←", Current:false, URL:"http://localhost:8080/?page=19&q=hello&source=test"}, - {Number:"11", Current:false, URL:"http://localhost:8080/?page=11&q=hello&source=test"}, - {Number:"12", Current:false, URL:"http://localhost:8080/?page=12&q=hello&source=test"}, - {Number:"13", Current:false, URL:"http://localhost:8080/?page=13&q=hello&source=test"}, - {Number:"14", Current:false, URL:"http://localhost:8080/?page=14&q=hello&source=test"}, - {Number:"15", Current:false, URL:"http://localhost:8080/?page=15&q=hello&source=test"}, - {Number:"16", Current:false, URL:"http://localhost:8080/?page=16&q=hello&source=test"}, - {Number:"17", Current:false, URL:"http://localhost:8080/?page=17&q=hello&source=test"}, - {Number:"18", Current:false, URL:"http://localhost:8080/?page=18&q=hello&source=test"}, - {Number:"19", Current:false, URL:"http://localhost:8080/?page=19&q=hello&source=test"}, - {Number:"20", Current:true, URL:"http://localhost:8080/?page=20&q=hello&source=test"}, - {Number:"→", Current:true, URL:"http://localhost:8080/?page=21&q=hello&source=test"}, - {Number:"»", Current:true, URL:"http://localhost:8080/?page=20&q=hello&source=test"}, + {Number: "«", Current: false, URL: "http://localhost:8080/?page=1&q=hello&source=test"}, + {Number: "←", Current: false, URL: "http://localhost:8080/?page=19&q=hello&source=test"}, + {Number: "11", Current: false, URL: "http://localhost:8080/?page=11&q=hello&source=test"}, + {Number: "12", Current: false, URL: "http://localhost:8080/?page=12&q=hello&source=test"}, + {Number: "13", Current: false, URL: "http://localhost:8080/?page=13&q=hello&source=test"}, + {Number: "14", Current: false, URL: "http://localhost:8080/?page=14&q=hello&source=test"}, + {Number: "15", Current: false, URL: "http://localhost:8080/?page=15&q=hello&source=test"}, + {Number: "16", Current: false, URL: "http://localhost:8080/?page=16&q=hello&source=test"}, + {Number: "17", Current: false, URL: "http://localhost:8080/?page=17&q=hello&source=test"}, + {Number: "18", Current: false, URL: "http://localhost:8080/?page=18&q=hello&source=test"}, + {Number: "19", Current: false, URL: "http://localhost:8080/?page=19&q=hello&source=test"}, + {Number: "20", Current: true, URL: "http://localhost:8080/?page=20&q=hello&source=test"}, + {Number: "→", Current: true, URL: "http://localhost:8080/?page=21&q=hello&source=test"}, + {Number: "»", Current: true, URL: "http://localhost:8080/?page=20&q=hello&source=test"}, }}, } diff --git a/app/server/server.go b/app/server/server.go index 1f6adb5..b91ba71 100644 --- a/app/server/server.go +++ b/app/server/server.go @@ -152,7 +152,7 @@ type togglableSource struct { func renderTemplateWithResults(db database.Database, config *config.Config, req *http.Request, w http.ResponseWriter, t *template.Template, templateName string) { src := req.URL.Query()["source"] q := req.URL.Query().Get("q") - page, err := strconv.ParseUint(req.URL.Query().Get("page"),10,32) + page, err := strconv.ParseUint(req.URL.Query().Get("page"), 10, 32) var results []database.Result var total *uint32 diff --git a/package.json b/package.json index cbbc9aa..91d3684 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ }, "lint-staged": { "*.tmpl": "prettier --write", - "*.go": "gofmt" + "*.go": "gofmt -w" }, "scripts": { "prepare": "husky install"