linters: add httpstatus linter

This commit is contained in:
2026-10-18 15:02:44 -07:00
parent 324de253c4
commit 01e6e04d14
9 changed files with 315 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
package cases
import "net/http"
const ok = http.StatusOK // want `HTTP status code 200 should use its integer literal`
const teapot = http.StatusTeapot
func response(w http.ResponseWriter, r *http.Request, code int) {
_ = http.StatusNotFound // want `HTTP status code 404 should use its integer literal`
http.Error(w, "bad request", http.StatusBadRequest) // want `HTTP status code 400 should use its integer literal`
http.Error(w, "teapot", http.StatusTeapot)
http.Error(w, "created", 201)
w.WriteHeader(http.StatusGatewayTimeout) // want `HTTP status code 504 should use its integer literal`
w.WriteHeader(code)
http.NotFound(w, r)
_, _ = w.Write([]byte("response"))
http.Redirect(w, r, "/login", http.StatusFound) // want `HTTP status code 302 should use its integer literal`
http.Redirect(w, r, "/other", http.StatusMovedPermanently)
}