chore: enhance golangci-lint configuration and clean up error handling

- Added new linters for the examples directory to improve code quality checks.
- Updated output formatting to direct lint results to stdout for better visibility.
- Cleaned up comments related to error handling in various files for clarity and consistency.
This commit is contained in:
0x524a
2025-12-03 00:14:24 -05:00
parent c939fb6563
commit bfad9e910c
10 changed files with 25 additions and 25 deletions
-2
View File
@@ -220,12 +220,10 @@ func main() {
log.Fatalf("Failed to create output file: %v", err)
}
defer func() {
//nolint:errcheck // Close error is not critical, file is already written
_ = f.Close()
}()
if err := tmpl.Execute(f, testData); err != nil {
//nolint:errcheck // Close error is not critical before fatal exit
_ = f.Close()
//nolint:gocritic // Fatalf exits, defer won't run - this is acceptable
log.Fatalf("Failed to execute template: %v", err)
+6 -6
View File
@@ -220,17 +220,17 @@ type ImageInfo struct {
}
// formatBytes converts bytes to human-readable format.
func formatBytes(bytes int64) string {
if bytes < bufferSize1024 {
return fmt.Sprintf("%d B", bytes)
func formatBytes(byteCount int64) string {
if byteCount < bufferSize1024 {
return fmt.Sprintf("%d B", byteCount)
}
const kbSize = 1024
const mbSize = 1024 * 1024
if bytes < mbSize {
return fmt.Sprintf("%.1f KB", float64(bytes)/kbSize)
if byteCount < mbSize {
return fmt.Sprintf("%.1f KB", float64(byteCount)/kbSize)
}
return fmt.Sprintf("%.1f MB", float64(bytes)/mbSize)
return fmt.Sprintf("%.1f MB", float64(byteCount)/mbSize)
}
// CreateASCIIHighQuality creates a high-quality ASCII representation.
-1
View File
@@ -690,7 +690,6 @@ func (c *CLI) tryRTSPConnection(streamURI string) map[string]interface{} {
// Try to connect
conn, err := net.DialTimeout("tcp", hostPort, maxRetries*time.Second)
if err == nil {
//nolint:errcheck // Close error is not critical for connectivity check
_ = conn.Close()
details["reachable"] = true
details["port"] = strings.Split(hostPort, ":")[1]
-4
View File
@@ -1102,21 +1102,18 @@ func createTarGz(sourceDir, archivePath string) error {
return fmt.Errorf("failed to create archive file: %w", err)
}
defer func() {
//nolint:errcheck // Close error is not critical for cleanup
_ = archiveFile.Close()
}()
// Create gzip writer
gzWriter := gzip.NewWriter(archiveFile)
defer func() {
//nolint:errcheck // Close error is not critical for cleanup
_ = gzWriter.Close()
}()
// Create tar writer
tarWriter := tar.NewWriter(gzWriter)
defer func() {
//nolint:errcheck // Close error is not critical for cleanup
_ = tarWriter.Close()
}()
@@ -1156,7 +1153,6 @@ func createTarGz(sourceDir, archivePath string) error {
return fmt.Errorf("failed to open file: %w", err)
}
defer func() {
//nolint:errcheck // Close error is not critical for cleanup
_ = file.Close()
}()