From a3f82fb11640545f26e536dd363015df22c14e7c Mon Sep 17 00:00:00 2001 From: valentimarco Date: Thu, 5 Dec 2024 19:07:19 +0100 Subject: [PATCH 1/3] feat: Exec `go mod tidy` after basic creation --- cmd/new.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/cmd/new.go b/cmd/new.go index 21f2aff..2f3c217 100644 --- a/cmd/new.go +++ b/cmd/new.go @@ -78,7 +78,18 @@ func createBasic(projectPath, modName string) (err error) { return } - return runCmd(execCommand("go", "mod", "init", modName)) + if err = runCmd(execCommand("go", "mod", "init", modName)); err != nil{ + return + } + + //Execute go mod tidy in the project directory + installModules := execCommand("go", "mod", "tidy") + installModules.Dir = fmt.Sprintf("%s%c", projectPath, os.PathSeparator) + if err = runCmd(installModules); err != nil{ + return + } + + return } const githubPrefix = "https://github.com/" From 66f65f090ce2771f7bd25dac8f18eba5267d4137 Mon Sep 17 00:00:00 2001 From: Juan Calderon-Perez <835733+gaby@users.noreply.github.com> Date: Sun, 1 Feb 2026 12:18:42 -0500 Subject: [PATCH 2/3] Fix error handling in new.go for module initialization --- cmd/new.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/new.go b/cmd/new.go index be0f702..4d03fbc 100644 --- a/cmd/new.go +++ b/cmd/new.go @@ -86,14 +86,14 @@ func createBasic(projectPath, modName string) error { return err } - if err = runCmd(execCommand("go", "mod", "init", modName)); err != nil{ + if err := runCmd(execCommand("go", "mod", "init", modName)); err != nil{ return } //Execute go mod tidy in the project directory installModules := execCommand("go", "mod", "tidy") installModules.Dir = fmt.Sprintf("%s%c", projectPath, os.PathSeparator) - if err = runCmd(installModules); err != nil{ + if err := runCmd(installModules); err != nil{ return } From 941a87d715e235c8e29e1546e89b12122f42ef7e Mon Sep 17 00:00:00 2001 From: Juan Calderon-Perez <835733+gaby@users.noreply.github.com> Date: Sun, 1 Feb 2026 12:22:17 -0500 Subject: [PATCH 3/3] Update cmd/new.go Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- cmd/new.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cmd/new.go b/cmd/new.go index 4d03fbc..5d87372 100644 --- a/cmd/new.go +++ b/cmd/new.go @@ -86,18 +86,18 @@ func createBasic(projectPath, modName string) error { return err } - if err := runCmd(execCommand("go", "mod", "init", modName)); err != nil{ - return + if err := runCmd(execCommand("go", "mod", "init", modName)); err != nil { + return err } //Execute go mod tidy in the project directory installModules := execCommand("go", "mod", "tidy") installModules.Dir = fmt.Sprintf("%s%c", projectPath, os.PathSeparator) - if err := runCmd(installModules); err != nil{ - return + if err := runCmd(installModules); err != nil { + return err } - return + return nil } const (