From e6e9dbdfb43c0e85072b0e47c95ab58f12b379a9 Mon Sep 17 00:00:00 2001 From: Steve Kuznetsov Date: Mon, 3 Oct 2022 06:55:10 -0600 Subject: [PATCH] output: ensure the directory exists When using +output:dir=./something and attempting to write a nested path, the current implementation does not work. Signed-off-by: Steve Kuznetsov --- pkg/genall/output.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/genall/output.go b/pkg/genall/output.go index b5a09e169..5dc3fe19c 100644 --- a/pkg/genall/output.go +++ b/pkg/genall/output.go @@ -103,7 +103,7 @@ type OutputToDirectory string func (o OutputToDirectory) Open(_ *loader.Package, itemPath string) (io.WriteCloser, error) { // ensure the directory exists - if err := os.MkdirAll(string(o), os.ModePerm); err != nil { + if err := os.MkdirAll(filepath.Dir(filepath.Join(string(o), itemPath)), os.ModePerm); err != nil { return nil, err } path := filepath.Join(string(o), itemPath)