Skip to content

Commit 5b6a16f

Browse files
fix: replace if-else chains with switch per gocritic lint
1 parent 00747e5 commit 5b6a16f

2 files changed

Lines changed: 12 additions & 9 deletions

File tree

internal/backup.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,12 @@ func Backup(ctx context.Context) {
4242
go func() {
4343
_, copyErr := io.Copy(pw, process)
4444
waitErr := process.Wait()
45-
if waitErr != nil {
45+
switch {
46+
case waitErr != nil:
4647
pw.CloseWithError(waitErr)
47-
} else if copyErr != nil {
48+
case copyErr != nil:
4849
pw.CloseWithError(copyErr)
49-
} else {
50+
default:
5051
pw.Close()
5152
}
5253
}()

internal/compress.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,12 @@ func Compress(input io.Reader) (io.ReadCloser, error) {
2929
go func() {
3030
_, copyErr := encoder.ReadFrom(input)
3131
closeErr := encoder.Close()
32-
if copyErr != nil {
32+
switch {
33+
case copyErr != nil:
3334
w.CloseWithError(copyErr)
34-
} else if closeErr != nil {
35+
case closeErr != nil:
3536
w.CloseWithError(closeErr)
36-
} else {
37+
default:
3738
w.Close()
3839
}
3940
}()
@@ -48,11 +49,12 @@ func Compress(input io.Reader) (io.ReadCloser, error) {
4849
go func() {
4950
_, copyErr := io.Copy(writer, input)
5051
closeErr := writer.Close()
51-
if copyErr != nil {
52+
switch {
53+
case copyErr != nil:
5254
w.CloseWithError(copyErr)
53-
} else if closeErr != nil {
55+
case closeErr != nil:
5456
w.CloseWithError(closeErr)
55-
} else {
57+
default:
5658
w.Close()
5759
}
5860
}()

0 commit comments

Comments
 (0)