diff options
| author | Paul Buetow <paul@buetow.org> | 2026-03-13 10:01:59 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-03-13 10:01:59 +0200 |
| commit | 44a426c883a2c448d40a19903c822d03e5cf70af (patch) | |
| tree | dbb1fe11db1993c2cac7daf1c9930e37f44b38d1 /internal/oi | |
| parent | cfddc5696f4956081630e3d394ef3d8c652af02e (diff) | |
chore: complete code quality audit fixesv1.2.6
- Fixed failing test in config_test.go (hardcoded date)
- Addressed unchecked error returns from Close() operations
- Refactored large functions to follow SRP (run.go and main.go)
- Added documentation to exported identifiers
- Fixed linting errors (error message capitalization, errcheck)
- Bumped version to v1.2.6
Diffstat (limited to 'internal/oi')
| -rw-r--r-- | internal/oi/oi.go | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/internal/oi/oi.go b/internal/oi/oi.go index 2f1bc1a..eac0cc2 100644 --- a/internal/oi/oi.go +++ b/internal/oi/oi.go @@ -9,6 +9,7 @@ import ( "strings" "time" + "codeberg.org/snonux/gos/internal/colour" "golang.org/x/exp/rand" ) @@ -117,7 +118,12 @@ func CopyFile(srcPath, dstPath string) error { if err != nil { return err } - defer source.Close() + defer func() { + if err := source.Close(); err != nil { + // Log the error but don't fail the operation since we've already read the data + colour.Errorln("Error closing source file:", err) + } + }() if err := EnsureParentDir(dstPath); err != nil { return err @@ -127,7 +133,12 @@ func CopyFile(srcPath, dstPath string) error { if err != nil { return err } - defer destination.Close() + defer func() { + if err := destination.Close(); err != nil { + // Log the error but don't fail the operation since we've already written the data + colour.Errorln("Error closing destination file:", err) + } + }() _, err = io.Copy(destination, source) return err @@ -154,7 +165,12 @@ func WriteFile(filePath, content string) error { if err != nil { return err } - defer file.Close() + defer func() { + if err := file.Close(); err != nil { + // Log the error but don't fail the operation since we've already written the data + colour.Errorln("Error closing file:", err) + } + }() _, err = file.WriteString(content) if err != nil { |
