chore(golangci-lint): bump golangci-lint to v2.10.1

This commit is contained in:
Julien Neuhart
2026-02-21 17:54:46 +01:00
parent be78a71bb7
commit 57e1b7efda
9 changed files with 17 additions and 15 deletions

View File

@@ -31,7 +31,7 @@ jobs:
- name: Run linters - name: Run linters
uses: golangci/golangci-lint-action@v9 uses: golangci/golangci-lint-action@v9
with: with:
version: v2.5.0 version: v2.10.1
lint-prettier: lint-prettier:
name: Lint non-Golang codebase name: Lint non-Golang codebase

View File

@@ -175,7 +175,7 @@ func (engine *ExifTool) WriteMetadata(ctx context.Context, logger *zap.Logger, m
strs[i] = str strs[i] = str
continue continue
} }
return fmt.Errorf("write PDF metadata with ExifTool: %s %+v %s %w", key, val, reflect.TypeFor[[]interface{}](), gotenberg.ErrPdfEngineMetadataValueNotSupported) return fmt.Errorf("write PDF metadata with ExifTool: %s %+v %s %w", key, val, reflect.TypeFor[[]any](), gotenberg.ErrPdfEngineMetadataValueNotSupported)
} }
fileMetadata[0].SetStrings(key, strs) fileMetadata[0].SetStrings(key, strs)
case bool: case bool:

View File

@@ -54,7 +54,7 @@ type Api struct {
// See: https://help.libreoffice.org/latest/en-US/text/shared/guide/pdf_params.html. // See: https://help.libreoffice.org/latest/en-US/text/shared/guide/pdf_params.html.
type Options struct { type Options struct {
// Password specifies the password for opening the source file. // Password specifies the password for opening the source file.
Password string Password string // #nosec
// Landscape allows changing the orientation of the resulting PDF. // Landscape allows changing the orientation of the resulting PDF.
Landscape bool Landscape bool

View File

@@ -177,7 +177,7 @@ func newLogLevel(level string) (zapcore.Level, error) {
} }
func newLogEncoder(format string, gcpFields bool) (zapcore.Encoder, error) { func newLogEncoder(format string, gcpFields bool) (zapcore.Encoder, error) {
isTerminal := term.IsTerminal(int(os.Stdout.Fd())) isTerminal := term.IsTerminal(int(os.Stdout.Fd())) // #nosec
encCfg := zap.NewProductionEncoderConfig() encCfg := zap.NewProductionEncoderConfig()
// Normalize the log format based on the output device. // Normalize the log format based on the output device.

View File

@@ -84,7 +84,7 @@ func (engine *PdfCpu) Debug() map[string]any {
// Merge combines multiple PDFs into a single PDF. // Merge combines multiple PDFs into a single PDF.
func (engine *PdfCpu) Merge(ctx context.Context, logger *zap.Logger, inputPaths []string, outputPath string) error { func (engine *PdfCpu) Merge(ctx context.Context, logger *zap.Logger, inputPaths []string, outputPath string) error {
var args []string args := make([]string, 0, 2+len(inputPaths))
args = append(args, "merge", outputPath) args = append(args, "merge", outputPath)
args = append(args, inputPaths...) args = append(args, inputPaths...)
@@ -180,10 +180,8 @@ func (engine *PdfCpu) EmbedFiles(ctx context.Context, logger *zap.Logger, filePa
logger.Debug(fmt.Sprintf("embedding %d file(s) to %s: %v", len(filePaths), inputPath, filePaths)) logger.Debug(fmt.Sprintf("embedding %d file(s) to %s: %v", len(filePaths), inputPath, filePaths))
args := []string{ args := make([]string, 0, 3+len(filePaths))
"attachments", "add", args = append(args, "attachments", "add", inputPath)
inputPath,
}
args = append(args, filePaths...) args = append(args, filePaths...)
cmd, err := gotenberg.CommandContext(ctx, logger, engine.binPath, args...) cmd, err := gotenberg.CommandContext(ctx, logger, engine.binPath, args...)
@@ -209,7 +207,7 @@ func (engine *PdfCpu) Encrypt(ctx context.Context, logger *zap.Logger, inputPath
ownerPassword = userPassword ownerPassword = userPassword
} }
var args []string args := make([]string, 0, 11)
args = append(args, "encrypt") args = append(args, "encrypt")
args = append(args, "-mode", "aes") args = append(args, "-mode", "aes")
args = append(args, "-upw", userPassword) args = append(args, "-upw", userPassword)

View File

@@ -108,7 +108,7 @@ func (engine *PdfTk) Split(ctx context.Context, logger *zap.Logger, mode gotenbe
// Merge combines multiple PDFs into a single PDF. // Merge combines multiple PDFs into a single PDF.
func (engine *PdfTk) Merge(ctx context.Context, logger *zap.Logger, inputPaths []string, outputPath string) error { func (engine *PdfTk) Merge(ctx context.Context, logger *zap.Logger, inputPaths []string, outputPath string) error {
var args []string args := make([]string, 0, 3+len(inputPaths))
args = append(args, inputPaths...) args = append(args, inputPaths...)
args = append(args, "cat", "output", outputPath) args = append(args, "cat", "output", outputPath)
@@ -158,7 +158,7 @@ func (engine *PdfTk) Encrypt(ctx context.Context, logger *zap.Logger, inputPath,
// Create a temp output file in the same directory. // Create a temp output file in the same directory.
tmpPath := inputPath + ".tmp" tmpPath := inputPath + ".tmp"
var args []string args := make([]string, 0, 8)
args = append(args, inputPath) args = append(args, inputPath)
args = append(args, "output", tmpPath) args = append(args, "output", tmpPath)
args = append(args, "encrypt_128bit") args = append(args, "encrypt_128bit")

View File

@@ -114,7 +114,7 @@ func (engine *QPdf) Split(ctx context.Context, logger *zap.Logger, mode gotenber
// Merge combines multiple PDFs into a single PDF. // Merge combines multiple PDFs into a single PDF.
func (engine *QPdf) Merge(ctx context.Context, logger *zap.Logger, inputPaths []string, outputPath string) error { func (engine *QPdf) Merge(ctx context.Context, logger *zap.Logger, inputPaths []string, outputPath string) error {
var args []string args := make([]string, 0, 4+len(engine.globalArgs)+len(inputPaths))
args = append(args, "--empty") args = append(args, "--empty")
args = append(args, engine.globalArgs...) args = append(args, engine.globalArgs...)
args = append(args, "--pages") args = append(args, "--pages")
@@ -137,7 +137,7 @@ func (engine *QPdf) Merge(ctx context.Context, logger *zap.Logger, inputPaths []
// Flatten merges annotation appearances with page content, deleting the // Flatten merges annotation appearances with page content, deleting the
// original annotations. // original annotations.
func (engine *QPdf) Flatten(ctx context.Context, logger *zap.Logger, inputPath string) error { func (engine *QPdf) Flatten(ctx context.Context, logger *zap.Logger, inputPath string) error {
var args []string args := make([]string, 0, 4+len(engine.globalArgs))
args = append(args, inputPath) args = append(args, inputPath)
args = append(args, "--generate-appearances") args = append(args, "--generate-appearances")
args = append(args, "--flatten-annotations=all") args = append(args, "--flatten-annotations=all")
@@ -182,7 +182,7 @@ func (engine *QPdf) Encrypt(ctx context.Context, logger *zap.Logger, inputPath,
ownerPassword = userPassword ownerPassword = userPassword
} }
var args []string args := make([]string, 0, 7+len(engine.globalArgs))
args = append(args, inputPath) args = append(args, inputPath)
args = append(args, engine.globalArgs...) args = append(args, engine.globalArgs...)
args = append(args, "--replace-input") args = append(args, "--replace-input")

View File

@@ -20,6 +20,7 @@ func doRequest(method, url string, headers map[string]string, body io.Reader) (*
req.Header.Set(header, value) req.Header.Set(header, value)
} }
// #nosec
resp, err := http.DefaultClient.Do(req) resp, err := http.DefaultClient.Do(req)
if err != nil { if err != nil {
return nil, fmt.Errorf("send a request: %w", err) return nil, fmt.Errorf("send a request: %w", err)
@@ -74,6 +75,7 @@ func doFormDataRequest(method, url string, fields map[string]string, files map[s
} }
req.Header.Set("Content-Type", writer.FormDataContentType()) req.Header.Set("Content-Type", writer.FormDataContentType())
// #nosec
resp, err := http.DefaultClient.Do(req) resp, err := http.DefaultClient.Do(req)
if err != nil { if err != nil {
return nil, fmt.Errorf("send a request: %w", err) return nil, fmt.Errorf("send a request: %w", err)

View File

@@ -79,12 +79,14 @@ func newServer(ctx context.Context, workdir string) (*server, error) {
} }
dirPath := fmt.Sprintf("%s/%s", workdir, s.req.Header.Get("Gotenberg-Trace")) dirPath := fmt.Sprintf("%s/%s", workdir, s.req.Header.Get("Gotenberg-Trace"))
// #nosec
err = os.MkdirAll(dirPath, 0o755) err = os.MkdirAll(dirPath, 0o755)
if err != nil { if err != nil {
return webhookErr(fmt.Errorf("create working directory: %w", err)) return webhookErr(fmt.Errorf("create working directory: %w", err))
} }
fpath := fmt.Sprintf("%s/%s", dirPath, filename) fpath := fmt.Sprintf("%s/%s", dirPath, filename)
// #nosec
file, err := os.Create(fpath) file, err := os.Create(fpath)
if err != nil { if err != nil {
return webhookErr(fmt.Errorf("create file %q: %w", fpath, err)) return webhookErr(fmt.Errorf("create file %q: %w", fpath, err))