Skip to content

Commit

Permalink
Merge pull request #4 from Axili39/mkdir
Browse files Browse the repository at this point in the history
make directory path if not exists
  • Loading branch information
rene-d authored May 11, 2021
2 parents d92b7b4 + 155ad24 commit 03a867c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion res2go.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package {{.Package}}
var {{.Prefix}}Files map[string][]byte
{{$prefix := .Prefix}}
func {{.Prefix}}Init(){
{{.Prefix}}Files = make(map[string][]byte)
{{.Prefix}}Files = make(map[string][]byte)
{{- range $name, $file := .Resources }}
{{$prefix}}Files["{{ $name }}"] = []byte{ {{ format $file }} }
{{- end }}
Expand Down Expand Up @@ -129,6 +129,12 @@ func main() {
os.Exit(1)
}

err = os.MkdirAll(filepath.Dir(*outputfile), os.ModePerm)
if err != nil {
fmt.Fprintln(os.Stderr, "Error creating directory path", err)
os.Exit(1)
}

err = ioutil.WriteFile(*outputfile, data, 0644)
if err != nil {
fmt.Fprintln(os.Stderr, "Error writing blob file", err)
Expand Down

0 comments on commit 03a867c

Please sign in to comment.