mirror of
https://github.com/go-admin-team/go-admin.git
synced 2026-09-29 12:31:11 +00:00
Preview, NOActionsGen and genApiToFile assigned each template's Execute error to err and never read it - 19 times - so a template failing part-way left a truncated file behind it and the request reported success. The files were written through pkg.FileCreate, which returns no error at all: when it cannot create a file it closes a nil *os.File and calls log.Fatalln, ending the server process. Four of the directories it writes into were created with _ = pkg.PathCreate(...). Every template now renders into memory first; if any fails, nothing is written and the response names the template. Files are then written through writeGenerated, which creates the directory and returns any error instead of exiting. NOActionsGen and genApiToFile report whether they succeeded, so GenCode and GenApiToFile no longer follow an error response with "Code generated successfully".