lint fixes

This commit is contained in:
2026-02-15 15:31:24 +00:00
parent 736d940d4e
commit 8cb1b8168f
2 changed files with 28 additions and 9 deletions

15
new.go
View File

@@ -19,9 +19,7 @@ const gitignoreFileName string = ".gitignore"
var newCmd = &cobra.Command{
Use: "new",
Short: "Create a new .gitignore file",
RunE: func(cmd *cobra.Command, args []string) error {
return runNewCommand(cmd, args)
},
RunE: runNewCommand,
}
func init() {
@@ -55,7 +53,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)
@@ -98,7 +100,10 @@ func runPrompt(client *gogi.Client, pc *promptConfig) (string, error) {
// commitGitignore writes the content of the selected gitignore template to the .gitignore file.
func commitGitignore(content string, w io.Writer) error {
if _, err := fmt.Fprintf(w, "# Generated by gogn: github.com/onyx-and-iris/gogn\n"); err != nil {
if _, err := fmt.Fprintf(
w,
"# Generated by gogn: github.com/onyx-and-iris/gogn\n",
); err != nil {
return fmt.Errorf("error writing header to file '%s': %w", gitignoreFileName, err)
}