From a3f82fb11640545f26e536dd363015df22c14e7c Mon Sep 17 00:00:00 2001 From: valentimarco Date: Thu, 5 Dec 2024 19:07:19 +0100 Subject: [PATCH] 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/"