Update project.go (#2024)

pull/2032/head
songzhibin97 3 years ago committed by GitHub
parent 0bbd008397
commit 398012aed4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 24
      cmd/kratos/internal/project/project.go

@ -68,26 +68,26 @@ func run(cmd *cobra.Command, args []string) {
go func() { go func() {
if !nomod { if !nomod {
done <- p.New(ctx, wd, repoURL, branch) done <- p.New(ctx, wd, repoURL, branch)
} else { return
if _, e := os.Stat(path.Join(wd, "go.mod")); os.IsNotExist(e) { }
done <- fmt.Errorf("🚫 go.mod don't exists in %s", wd) if _, e := os.Stat(path.Join(wd, "go.mod")); os.IsNotExist(e) {
return done <- fmt.Errorf("🚫 go.mod don't exists in %s", wd)
} return
}
mod, e := base.ModulePath(path.Join(wd, "go.mod")) mod, e := base.ModulePath(path.Join(wd, "go.mod"))
if e != nil { if e != nil {
panic(e) panic(e)
}
done <- p.Add(ctx, wd, repoURL, branch, mod)
} }
done <- p.Add(ctx, wd, repoURL, branch, mod)
}() }()
select { select {
case <-ctx.Done(): case <-ctx.Done():
if errors.Is(ctx.Err(), context.DeadlineExceeded) { if errors.Is(ctx.Err(), context.DeadlineExceeded) {
fmt.Fprint(os.Stderr, "\033[31mERROR: project creation timed out\033[m\n") fmt.Fprint(os.Stderr, "\033[31mERROR: project creation timed out\033[m\n")
} else { return
fmt.Fprintf(os.Stderr, "\033[31mERROR: failed to create project(%s)\033[m\n", ctx.Err().Error())
} }
fmt.Fprintf(os.Stderr, "\033[31mERROR: failed to create project(%s)\033[m\n", ctx.Err().Error())
case err = <-done: case err = <-done:
if err != nil { if err != nil {
fmt.Fprintf(os.Stderr, "\033[31mERROR: Failed to create project(%s)\033[m\n", err.Error()) fmt.Fprintf(os.Stderr, "\033[31mERROR: Failed to create project(%s)\033[m\n", err.Error())

Loading…
Cancel
Save