fix: address /home/stevan/go/bin/golangci-lint run ./... issues

This commit is contained in:
Stevan Freeborn
2026-08-15 22:09:59 -05:00
parent 9eca3c71e2
commit 19f5aca484
3 changed files with 14 additions and 5 deletions
+3 -1
View File
@@ -96,6 +96,8 @@ func GetAPIKey(headers http.Header) (string, error) {
// token. // token.
func MakeRefreshToken() string { func MakeRefreshToken() string {
bytes := make([]byte, 32) bytes := make([]byte, 32)
rand.Read(bytes) if _, err := rand.Read(bytes); err != nil {
panic(err)
}
return hex.EncodeToString(bytes) return hex.EncodeToString(bytes)
} }
+8 -1
View File
@@ -13,9 +13,16 @@ func TestJwtCreationAndValidation(t *testing.T) {
secret := []byte("RTCK2UTcOUkiswdrClC6Z3KmmEq/+QicpD9iRx7J0qY=") secret := []byte("RTCK2UTcOUkiswdrClC6Z3KmmEq/+QicpD9iRx7J0qY=")
jwtString, err := auth.MakeJWT(userId, secret, time.Hour) jwtString, err := auth.MakeJWT(userId, secret, time.Hour)
if err != nil {
t.Fatalf("failed to create JWT: %v", err)
}
validatedUserId, err := auth.ValidateJWT(jwtString, secret) validatedUserId, err := auth.ValidateJWT(jwtString, secret)
if err != nil {
t.Fatalf("failed to validate JWT: %v", err)
}
if userId != validatedUserId { if userId != validatedUserId {
t.Fatalf("received %s expected %s: %v", validatedUserId, userId, err) t.Fatalf("received %s expected %s", validatedUserId, userId)
} }
} }
+3 -3
View File
@@ -23,14 +23,14 @@ func (s *Server) HandleIndex(w http.ResponseWriter, r *http.Request) {
w.Header().Add("Content-Type", "text/html; charset=utf-8") w.Header().Add("Content-Type", "text/html; charset=utf-8")
w.WriteHeader(http.StatusOK) w.WriteHeader(http.StatusOK)
w.Write(s.indexHTML) _, _ = w.Write(s.indexHTML)
} }
// HandleHealthChecks reports that the service is up. // HandleHealthChecks reports that the service is up.
func (s *Server) HandleHealthChecks(w http.ResponseWriter, r *http.Request) { func (s *Server) HandleHealthChecks(w http.ResponseWriter, r *http.Request) {
w.Header().Add("Content-Type", "text/plain; charset=utf-8") w.Header().Add("Content-Type", "text/plain; charset=utf-8")
w.WriteHeader(http.StatusOK) w.WriteHeader(http.StatusOK)
w.Write([]byte("OK")) _, _ = w.Write([]byte("OK"))
} }
// HandleReset clears the file server hit counter and deletes all users. It is // HandleReset clears the file server hit counter and deletes all users. It is
@@ -50,7 +50,7 @@ func (s *Server) HandleReset(w http.ResponseWriter, r *http.Request) {
w.Header().Add("Content-Type", "text/plain; charset=utf-8") w.Header().Add("Content-Type", "text/plain; charset=utf-8")
w.WriteHeader(http.StatusOK) w.WriteHeader(http.StatusOK)
w.Write([]byte("OK")) _, _ = w.Write([]byte("OK"))
} }
// HandleMetrics renders the admin page showing how many times the file server // HandleMetrics renders the admin page showing how many times the file server