Skip to content

Commit 0079d14

Browse files
committed
bump golangci-lint to v2
Signed-off-by: Avi Deitcher <avi@deitcher.net>
1 parent 25cb740 commit 0079d14

File tree

17 files changed

+36
-37
lines changed

17 files changed

+36
-37
lines changed

.github/workflows/ci.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ jobs:
6161
with:
6262
go-version: '1.23'
6363
- name: golangci-lint
64-
uses: golangci/golangci-lint-action@v6
64+
uses: golangci/golangci-lint-action@v7
6565
with:
66-
version: latest
66+
version: v2.1.2
6767
- name: Build
6868
run: go build -o dist/mysql-backup -v .
6969
- name: vet

cmd/dump.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func dumpCmd(passedExecs execs, cmdConfig *cmdConfiguration) (*cobra.Command, er
5050
cmdConfig.logger.Debug("starting dump")
5151
defer func() {
5252
tp := getTracerProvider()
53-
tp.ForceFlush(ctx)
53+
_ = tp.ForceFlush(ctx)
5454
_ = tp.Shutdown(ctx)
5555
}()
5656
// check targets

cmd/prune.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func pruneCmd(passedExecs execs, cmdConfig *cmdConfiguration) (*cobra.Command, e
3737
// this is the tracer that we will use throughout the entire run
3838
defer func() {
3939
tp := getTracerProvider()
40-
tp.ForceFlush(ctx)
40+
_ = tp.ForceFlush(ctx)
4141
_ = tp.Shutdown(ctx)
4242
}()
4343
tracer := getTracer("prune")

cmd/restore.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func restoreCmd(passedExecs execs, cmdConfig *cmdConfiguration) (*cobra.Command,
3535
tracer := getTracer("restore")
3636
defer func() {
3737
tp := getTracerProvider()
38-
tp.ForceFlush(ctx)
38+
_ = tp.ForceFlush(ctx)
3939
_ = tp.Shutdown(ctx)
4040
}()
4141
ctx = util.ContextWithTracer(ctx, tracer)

cmd/root.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ func rootCmd(execs execs) (*cobra.Command, error) {
101101
if f, err = os.Open(configFilePath); err != nil {
102102
return fmt.Errorf("fatal error config file: %w", err)
103103
}
104-
defer f.Close()
104+
defer func() { _ = f.Close() }()
105105
actualConfig, err = config.ProcessConfig(f)
106106
if err != nil {
107107
return fmt.Errorf("unable to read provided config: %w", err)

pkg/archive/tar.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ func Tar(src string, writer io.WriteCloser) error {
1919
tw := tar.NewWriter(writer)
2020
// defers are executed via a stack, so LIFO
2121
// important we close the tw before the underlying writer
22-
defer writer.Close()
23-
defer tw.Close()
22+
defer func() { _ = tw.Close(); _ = writer.Close() }()
2423

2524
// walk path
2625
return filepath.Walk(src, func(file string, fi os.FileInfo, err error) error {
@@ -42,7 +41,7 @@ func Tar(src string, writer io.WriteCloser) error {
4241
}
4342

4443
// update the name to correctly reflect the desired destination when untaring
45-
header.Name = strings.TrimPrefix(strings.Replace(file, src, "", -1), string(filepath.Separator))
44+
header.Name = strings.TrimPrefix(strings.ReplaceAll(file, src, ""), string(filepath.Separator))
4645

4746
// write the header
4847
if err := tw.WriteHeader(header); err != nil {
@@ -62,7 +61,7 @@ func Tar(src string, writer io.WriteCloser) error {
6261

6362
// manually close here after each file operation; defering would cause each file close
6463
// to wait until all operations have completed.
65-
f.Close()
64+
_ = f.Close()
6665

6766
return nil
6867
})
@@ -121,7 +120,7 @@ func Untar(r io.Reader, dst string) error {
121120

122121
// manually close here after each file operation; defering would cause each file close
123122
// to wait until all operations have completed.
124-
f.Close()
123+
_ = f.Close()
125124
}
126125
}
127126
}

pkg/config/process.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ func getRemoteConfig(spec api.RemoteSpec) (conf api.Config, err error) {
106106
if err != nil {
107107
return conf, fmt.Errorf("error getting reader: %w", err)
108108
}
109-
defer resp.Body.Close()
109+
defer func() { _ = resp.Body.Close() }()
110110

111111
// Read the body of the response and convert to a config.Config struct
112112
var baseConf api.Config

pkg/core/dump.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func (e *Executor) Dump(ctx context.Context, opts DumpOptions) (DumpResults, err
6666
if err != nil {
6767
return results, fmt.Errorf("failed to make temporary working directory: %v", err)
6868
}
69-
defer os.RemoveAll(tmpdir)
69+
defer func() { _ = os.RemoveAll(tmpdir) }()
7070
// execute pre-backup scripts if any
7171
if err := preBackup(ctx, timepart, path.Join(tmpdir, sourceFilename), tmpdir, opts.PreBackupScripts, logger.Level == log.DebugLevel); err != nil {
7272
return results, fmt.Errorf("error running pre-restore: %v", err)
@@ -77,7 +77,7 @@ func (e *Executor) Dump(ctx context.Context, opts DumpOptions) (DumpResults, err
7777
if err != nil {
7878
return results, fmt.Errorf("failed to make temporary cache directory: %v", err)
7979
}
80-
defer os.RemoveAll(workdir)
80+
defer func() { _ = os.RemoveAll(workdir) }()
8181

8282
dw := make([]database.DumpWriter, 0)
8383

@@ -125,7 +125,7 @@ func (e *Executor) Dump(ctx context.Context, opts DumpOptions) (DumpResults, err
125125
tarSpan.End()
126126
return results, fmt.Errorf("failed to open output file '%s': %v", outFile, err)
127127
}
128-
defer f.Close()
128+
defer func() { _ = f.Close() }()
129129
cw, err := compressor.Compress(f)
130130
if err != nil {
131131
tarSpan.SetStatus(codes.Error, err.Error())
@@ -138,7 +138,7 @@ func (e *Executor) Dump(ctx context.Context, opts DumpOptions) (DumpResults, err
138138
return results, fmt.Errorf("error creating the compressed archive: %v", err)
139139
}
140140
// we need to close it explicitly before moving ahead
141-
f.Close()
141+
defer func() { _ = f.Close() }()
142142
tarSpan.SetStatus(codes.Ok, "completed")
143143
tarSpan.End()
144144

pkg/core/restore.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,13 @@ func (e *Executor) Restore(ctx context.Context, opts RestoreOptions) error {
6060
if err != nil {
6161
return fmt.Errorf("unable to create temporary working directory: %v", err)
6262
}
63-
defer os.RemoveAll(tmpdir)
63+
defer func() { _ = os.RemoveAll(tmpdir) }()
6464
f, err := os.Open(tmpRestoreFile)
6565
if f == nil {
6666
return fmt.Errorf("unable to read the temporary download file: %v", err)
6767
}
68-
defer f.Close()
69-
defer os.Remove(tmpRestoreFile)
68+
defer func() { _ = f.Close() }()
69+
defer func() { _ = os.Remove(tmpRestoreFile) }()
7070

7171
// create my tar reader to put the files in the directory
7272
_, tarSpan := tracer.Start(ctx, "input_tar")
@@ -105,7 +105,7 @@ func (e *Executor) Restore(ctx context.Context, opts RestoreOptions) error {
105105
if err != nil {
106106
continue
107107
}
108-
defer file.Close()
108+
defer func() { _ = file.Close() }()
109109
readers = append(readers, file)
110110
fileNames = append(fileNames, f.Name())
111111
}

pkg/database/dump.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func Dump(ctx context.Context, dbconn Connection, opts DumpOpts, writers []DumpW
2828
if err != nil {
2929
return fmt.Errorf("failed to open connection to database: %v", err)
3030
}
31-
defer db.Close()
31+
defer func() { _ = db.Close() }()
3232
for _, schema := range writer.Schemas {
3333
dumper := &mysql.Data{
3434
Out: writer.Writer,

0 commit comments

Comments
 (0)