This commit is contained in:
maddalax 2024-09-23 16:54:31 -05:00
parent 33d63a564e
commit 09ad76e01d

View file

@ -7,6 +7,7 @@ import (
"go/parser"
"go/token"
"log"
"log/slog"
"os"
"path/filepath"
)
@ -16,6 +17,8 @@ func WriteFile(path string, cb func(content *ast.File) string) {
path = filepath.Join(currentDir, path)
slog.Debug("astgen.WriteFile", slog.String("path", path))
dir := filepath.Dir(path)
os.MkdirAll(dir, 0755)
@ -49,7 +52,7 @@ func WriteFile(path string, cb func(content *ast.File) string) {
bytes, err = format.Source(bytes)
if err != nil {
log.Printf("Failed to format source: %v\n\n%s", err)
log.Printf("Failed to format source: %v\n", err.Error())
data := string(bytes)
println(data)
return