diff --git a/cli/module_generate.go b/cli/module_generate.go index 52c5ac90b89..79f4c19195d 100644 --- a/cli/module_generate.go +++ b/cli/module_generate.go @@ -787,6 +787,15 @@ func generateGolangStubs(module modulegen.ModuleInputs) error { return errors.Wrap(err, "cannot generate go stubs -- unable to sort imports") } + // run go mod tidy + if module.Language == golang { + tidyCmd := exec.Command("go", "mod", "tidy") + tidyCmd.Dir = module.ModuleName + if err := tidyCmd.Run(); err != nil { + return fmt.Errorf("failed to run go mod tidy: %w", err) + } + } + return nil } diff --git a/cli/module_generate/_templates/go/tmpl-go.mod b/cli/module_generate/_templates/go/tmpl-go.mod index 4256aaa08eb..f06a3844dcd 100644 --- a/cli/module_generate/_templates/go/tmpl-go.mod +++ b/cli/module_generate/_templates/go/tmpl-go.mod @@ -1,3 +1,3 @@ module {{.ModuleLowercase}} -go 1.23 +go 1.25