diff --git a/cmd/gf/internal/cmd/cmd_init.go b/cmd/gf/internal/cmd/cmd_init.go index ce8d024e3..ac2472756 100644 --- a/cmd/gf/internal/cmd/cmd_init.go +++ b/cmd/gf/internal/cmd/cmd_init.go @@ -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! ")