improve command init: add go mod tidy for init project (#2083)

* CI updates

* improve command init
This commit is contained in:
John Guo 2022-08-22 14:31:35 +08:00 committed by GitHub
parent 3988a7ff6b
commit 25d4ba320a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -94,6 +94,7 @@ func (c cInit) Index(ctx context.Context, in cInitInput) (out *cInitOutput, err
// Update the GoFrame version.
if in.Update {
mlog.Print("update goframe...")
// go get -u github.com/gogf/gf/v2@latest
updateCommand := `go get -u github.com/gogf/gf/v2@latest`
if in.Name != "." {
updateCommand = fmt.Sprintf(`cd %s && %s`, in.Name, updateCommand)
@ -101,6 +102,14 @@ func (c cInit) Index(ctx context.Context, in cInitInput) (out *cInitOutput, err
if err = gproc.ShellRun(ctx, updateCommand); err != nil {
mlog.Fatal(err)
}
// go mod tidy
gomModTidyCommand := `go mod tidy`
if in.Name != "." {
gomModTidyCommand = fmt.Sprintf(`cd %s && %s`, in.Name, gomModTidyCommand)
}
if err = gproc.ShellRun(ctx, gomModTidyCommand); err != nil {
mlog.Fatal(err)
}
}
mlog.Print("initialization done! ")