feat: create output directory ()

This commit is contained in:
Ludovic Fernandez 2024-03-17 23:07:50 +01:00 committed by GitHub
parent 7ad5ccb65b
commit d37a3e0951
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -5,6 +5,7 @@ import (
"fmt"
"io"
"os"
"path/filepath"
"strings"
"github.com/golangci/golangci-lint/pkg/config"
@ -99,6 +100,11 @@ func (c *Printer) createWriter(path string) (io.Writer, bool, error) {
return c.stdErr, false, nil
}
err := os.MkdirAll(filepath.Dir(path), os.ModePerm)
if err != nil {
return nil, false, err
}
f, err := os.OpenFile(path, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, defaultFileMode)
if err != nil {
return nil, false, err