Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 (go/v4): Scaffold when no boilerplate file #3378

Merged
merged 2 commits into from
May 2, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/plugins/golang/v4/scaffolds/api.go
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func (s *apiScaffolder) Scaffold() error {
// Load the boilerplate
boilerplate, err := afero.ReadFile(s.fs.FS, hack.DefaultBoilerplatePath)
if err != nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we specifyically check for fileNotFound error and skip with errors.Is(err, afero.ErrFileNotFound). In case its something else (like permission issue), we can return the error.

Copy link
Member

@camilamacedo86 camilamacedo86 May 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 in in the above suggestion.

We need only to use an empty string when we know the file does not exist.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! It's very helpful. 😀 I made changes on this.

return fmt.Errorf("error scaffolding API/controller: unable to load boilerplate: %w", err)
boilerplate = []byte("")
}

// Initialize the machinery.Scaffold that will write the files to disk
Expand Down