From 78210b0b9a1b1fbbef0111ad44cacdd67b3decc9 Mon Sep 17 00:00:00 2001 From: Chris Roche Date: Wed, 21 Nov 2018 19:07:34 -0800 Subject: [PATCH] create dir before writing file (#43) --- protoc-gen-debug/main.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/protoc-gen-debug/main.go b/protoc-gen-debug/main.go index 87a1d64..584f2ee 100644 --- a/protoc-gen-debug/main.go +++ b/protoc-gen-debug/main.go @@ -31,8 +31,13 @@ func main() { log.Fatal(`please execute the plugin with the output path to properly write the output file: --debug_out="{PATH}:{PATH}"`) } + err = os.MkdirAll(path, 0755) + if err != nil { + log.Fatal("unable to create output dir: ", err) + } + err = ioutil.WriteFile(filepath.Join(path, "code_generator_request.pb.bin"), data, 0644) - if path == "" { + if err != nil { log.Fatal("unable to write request to disk: ", err) }