fix: address /home/stevan/go/bin/golangci-lint run ./... issues
This commit is contained in:
@@ -96,6 +96,8 @@ func GetAPIKey(headers http.Header) (string, error) {
|
||||
// token.
|
||||
func MakeRefreshToken() string {
|
||||
bytes := make([]byte, 32)
|
||||
rand.Read(bytes)
|
||||
if _, err := rand.Read(bytes); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return hex.EncodeToString(bytes)
|
||||
}
|
||||
|
||||
@@ -13,9 +13,16 @@ func TestJwtCreationAndValidation(t *testing.T) {
|
||||
secret := []byte("RTCK2UTcOUkiswdrClC6Z3KmmEq/+QicpD9iRx7J0qY=")
|
||||
|
||||
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)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to validate JWT: %v", err)
|
||||
}
|
||||
|
||||
if userId != validatedUserId {
|
||||
t.Fatalf("received %s expected %s: %v", validatedUserId, userId, err)
|
||||
t.Fatalf("received %s expected %s", validatedUserId, userId)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.WriteHeader(http.StatusOK)
|
||||
w.Write(s.indexHTML)
|
||||
_, _ = w.Write(s.indexHTML)
|
||||
}
|
||||
|
||||
// HandleHealthChecks reports that the service is up.
|
||||
func (s *Server) HandleHealthChecks(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Add("Content-Type", "text/plain; charset=utf-8")
|
||||
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
|
||||
@@ -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.WriteHeader(http.StatusOK)
|
||||
w.Write([]byte("OK"))
|
||||
_, _ = w.Write([]byte("OK"))
|
||||
}
|
||||
|
||||
// HandleMetrics renders the admin page showing how many times the file server
|
||||
|
||||
Reference in New Issue
Block a user