summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuka Markušić <markusicluka@gmail.com>2022-08-03 13:57:26 +0200
committerGitHub <noreply@github.com>2022-08-03 13:57:26 +0200
commit64224e7caaad745f988c7e153f74a5b5bf2e5077 (patch)
treeeabbbf19302560ac9c660065876bcde25c0698e6
parentd56bb0b8ef0d9f3289e6e47288d79ed4d84088b0 (diff)
Update pkg/commands/oscommands/os.go
Co-authored-by: Ryoga <eial5q265e5+github@gmail.com>
-rw-r--r--pkg/commands/oscommands/os.go10
1 files changed, 5 insertions, 5 deletions
diff --git a/pkg/commands/oscommands/os.go b/pkg/commands/oscommands/os.go
index 5f89f976f..2a7cc1328 100644
--- a/pkg/commands/oscommands/os.go
+++ b/pkg/commands/oscommands/os.go
@@ -120,17 +120,17 @@ func (c *OSCommand) AppendLineToFile(filename, line string) error {
return utils.WrapError(err)
}
- buf := make([]byte, 1)
if info.Size() > 0 {
// read last char
+ buf := make([]byte, 1)
if _, err := f.ReadAt(buf, info.Size()-1); err != nil {
return utils.WrapError(err)
}
- }
- // if the last byte of the file is not a newline, add it
- if []byte("\n")[0] != buf[0] {
- _, err = f.WriteString("\n")
+ // if the last byte of the file is not a newline, add it
+ if []byte("\n")[0] != buf[0] {
+ _, err = f.WriteString("\n")
+ }
}
if err == nil {