From 6c784b70363679978104c0da8f489de5dd69ee2e Mon Sep 17 00:00:00 2001 From: "Gustavo \"Guz\" L. de Mello" Date: Mon, 24 Jun 2024 16:11:10 -0300 Subject: [PATCH] chore: lint command and hook --- .hooks/pre-commit | 3 +++ api/robots.go | 5 ++++- makefile | 3 +++ 3 files changed, 10 insertions(+), 1 deletion(-) create mode 100755 .hooks/pre-commit diff --git a/.hooks/pre-commit b/.hooks/pre-commit new file mode 100755 index 0000000..aeb4b9c --- /dev/null +++ b/.hooks/pre-commit @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +make lint diff --git a/api/robots.go b/api/robots.go index 82cfa7e..d066485 100644 --- a/api/robots.go +++ b/api/robots.go @@ -19,7 +19,10 @@ func RobotsTxt(w http.ResponseWriter, r *http.Request) { if error("Error trying to read ai block list", err, http.StatusInternalServerError) { return } - w.Write(bytes) + _, err = w.Write(bytes) + if error("Error trying to write ai block list", err, http.StatusInternalServerError) { + return + } w.Header().Add("Cache-Control", "max-age=604800, stale-while-revalidate=86400, stale-if-error=86400") w.Header().Add("CDN-Cache-Control", "max-age=604800") diff --git a/makefile b/makefile index 6552603..dafcbe6 100644 --- a/makefile +++ b/makefile @@ -1,5 +1,8 @@ PORT?=8080 +lint: + go run github.com/golangci/golangci-lint/cmd/golangci-lint@v1.59.1 run + build: templ go build -o bin/www