Merge pull request #2 from rdarius/styles

style check
This commit is contained in:
RDarius
2025-03-16 13:53:52 +02:00
committed by GitHub
3 changed files with 41 additions and 4 deletions

View File

@@ -18,5 +18,35 @@ jobs:
with:
go-version: "1.23.0"
- name: Install gosec
run: go install github.com/securego/gosec/v2/cmd/gosec@latest
- name: Tests
run: go test ./... -cover
run: go test ./... -cover
- name: Security Checks
run: gosec ./...
style:
name: Style
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.23.0"
- name: Install staticcheck
uses: dominikh/staticcheck-action@v1
with:
version: "latest"
- name: Style
run: test -z $(go fmt ./...)
- name: Linting
run: test -z $(go fmt ./...)

View File

@@ -2,6 +2,7 @@ package main
import (
"encoding/json"
"fmt"
"log"
"net/http"
)
@@ -30,5 +31,9 @@ func respondWithJSON(w http.ResponseWriter, code int, payload interface{}) {
return
}
w.WriteHeader(code)
w.Write(dat)
_, err = w.Write(dat)
if err != nil {
fmt.Printf("Error wiring response: %s", err.Error())
return
}
}

View File

@@ -7,6 +7,7 @@ import (
"log"
"net/http"
"os"
"time"
"github.com/go-chi/chi"
"github.com/go-chi/cors"
@@ -89,8 +90,9 @@ func main() {
router.Mount("/v1", v1Router)
srv := &http.Server{
Addr: ":" + port,
Handler: router,
Addr: ":" + port,
Handler: router,
ReadHeaderTimeout: time.Second * 30,
}
log.Printf("Serving on port: %s\n", port)