diff --git a/v2/cmd/wails/init.go b/v2/cmd/wails/init.go index 709905c0f..f79e37ffc 100644 --- a/v2/cmd/wails/init.go +++ b/v2/cmd/wails/init.go @@ -125,6 +125,12 @@ func initProject(f *flags.Init) error { return err } + // Change the module name to project name + err = updateModuleNameToProjectName(options, quiet) + if err != nil { + return err + } + if !f.CIMode { // Run `go mod tidy` to ensure `go.sum` is up to date cmd := exec.Command("go", "mod", "tidy") @@ -276,3 +282,14 @@ func updateReplaceLine(targetPath string) { fatal(err.Error()) } } + +func updateModuleNameToProjectName(options *templates.Options, quiet bool) error { + cmd := exec.Command("go", "mod", "edit", "-module", options.ProjectName) + cmd.Dir = options.TargetDir + cmd.Stderr = os.Stderr + if !quiet { + cmd.Stdout = os.Stdout + } + + return cmd.Run() +} diff --git a/website/src/pages/changelog.mdx b/website/src/pages/changelog.mdx index 4166f46e1..fba49d82d 100644 --- a/website/src/pages/changelog.mdx +++ b/website/src/pages/changelog.mdx @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added docs to help fix NixOs/Wayland font-size css issue. Added by @atterpac in [PR](https://github.com/wailsapp/wails/pull/3268) - Added -m (skip `go mod tidy`) flag to dev command by @te5se in [PR](https://github.com/wailsapp/wails/pull/3275) - Added mac option `DisableZoom` to remove zoom button. Added by @wizzymore in [PR](https://github.com/wailsapp/wails/pull/3289) +- Changed Create a project with changing the default name to the project’s name. Changed by [@Twacqwq](https://github.com/Twacqwq) in [PR](https://github.com/wailsapp/wails/pull/3303) ## v2.8.0 - 2024-02-08