mirror of
https://github.com/onyx-and-iris/ignr.git
synced 2026-04-18 23:33:33 +00:00
lint fixes
This commit is contained in:
16
new.go
16
new.go
@@ -20,9 +20,7 @@ var newCmd = &cobra.Command{
|
||||
Use: "new",
|
||||
Short: "Create a new .gitignore file",
|
||||
Args: cobra.NoArgs,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return runNewCommand(cmd, args)
|
||||
},
|
||||
RunE: runNewCommand,
|
||||
}
|
||||
|
||||
func init() {
|
||||
@@ -61,7 +59,11 @@ func runNewCommand(cmd *cobra.Command, _ []string) error {
|
||||
if err != nil {
|
||||
return fmt.Errorf("error opening file '%s': %w", gitignoreFileName, err)
|
||||
}
|
||||
defer f.Close()
|
||||
defer func() {
|
||||
if err := f.Close(); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "error closing file '%s': %v\n", gitignoreFileName, err)
|
||||
}
|
||||
}()
|
||||
|
||||
if err = commitGitignore(content, f); err != nil {
|
||||
return fmt.Errorf("error committing gitignore file: %w", err)
|
||||
@@ -108,7 +110,11 @@ func runPrompt(client *github.Client, pc *promptConfig) (*github.Gitignore, erro
|
||||
|
||||
// commitGitignore writes the content of the selected gitignore template to the .gitignore file.
|
||||
func commitGitignore(content *github.Gitignore, w io.Writer) error {
|
||||
if _, err := fmt.Fprintf(w, "# Generated by ignr: github.com/onyx-and-iris/ignr\n\n## %s ##\n", content.GetName()); err != nil {
|
||||
if _, err := fmt.Fprintf(
|
||||
w,
|
||||
"# Generated by ignr: github.com/onyx-and-iris/ignr\n\n## %s ##\n",
|
||||
content.GetName(),
|
||||
); err != nil {
|
||||
return fmt.Errorf("error writing header to file '%s': %w", gitignoreFileName, err)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user