From d57a3c2a8bc0380c322ae468c6a62c8bacda3798 Mon Sep 17 00:00:00 2001 From: songzhibin97 <49082129+songzhibin97@users.noreply.github.com> Date: Sun, 22 May 2022 10:03:12 +0800 Subject: [PATCH] Update project.go (#2024) --- cmd/kratos/internal/project/project.go | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/cmd/kratos/internal/project/project.go b/cmd/kratos/internal/project/project.go index bfad066bf..8ea7f2a99 100644 --- a/cmd/kratos/internal/project/project.go +++ b/cmd/kratos/internal/project/project.go @@ -68,26 +68,26 @@ func run(cmd *cobra.Command, args []string) { go func() { if !nomod { done <- p.New(ctx, wd, repoURL, branch) - } else { - if _, e := os.Stat(path.Join(wd, "go.mod")); os.IsNotExist(e) { - done <- fmt.Errorf("🚫 go.mod don't exists in %s", wd) - return - } + return + } + if _, e := os.Stat(path.Join(wd, "go.mod")); os.IsNotExist(e) { + done <- fmt.Errorf("🚫 go.mod don't exists in %s", wd) + return + } - mod, e := base.ModulePath(path.Join(wd, "go.mod")) - if e != nil { - panic(e) - } - done <- p.Add(ctx, wd, repoURL, branch, mod) + mod, e := base.ModulePath(path.Join(wd, "go.mod")) + if e != nil { + panic(e) } + done <- p.Add(ctx, wd, repoURL, branch, mod) }() select { case <-ctx.Done(): if errors.Is(ctx.Err(), context.DeadlineExceeded) { fmt.Fprint(os.Stderr, "\033[31mERROR: project creation timed out\033[m\n") - } else { - fmt.Fprintf(os.Stderr, "\033[31mERROR: failed to create project(%s)\033[m\n", ctx.Err().Error()) + return } + fmt.Fprintf(os.Stderr, "\033[31mERROR: failed to create project(%s)\033[m\n", ctx.Err().Error()) case err = <-done: if err != nil { fmt.Fprintf(os.Stderr, "\033[31mERROR: Failed to create project(%s)\033[m\n", err.Error())