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() {
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())

Loading…
Cancel
Save