About this tool
Generate a valid go.mod with module path, go and toolchain directives, require, replace, exclude and retract blocks.
A go.mod generator builds the module definition file that the go command reads to resolve dependencies: the module path, the go language version, an optional toolchain line, and the require, replace, exclude and retract directives. It validates your input against the rules in the Go Modules Reference — canonical semantic versions of the form vMAJOR.MINOR.PATCH, and the major version suffix rule that forces any module at v2 or above to end its path with /vN. Useful when you are starting a module by hand, vendoring a fork through a replace, or reviewing a go.mod in a code review.
Open Go Mod Generator on AltFTool — it loads instantly in your browser.
Provide your input — an image, text, or data.
Let the tool analyze or generate the result.
Review, refine, and reuse the output wherever you need it.
Flags a v2-or-higher version whose module path is missing the required major version suffix.
Emits module, go, toolchain, require, replace, exclude and retract in the layout go mod tidy produces.
Module paths and internal package names are never uploaded anywhere.
Because the import compatibility rule says a new major version is a different module. From v2 onwards the module path must end with the element /vN, so github.com/user/repo/v2 and github.com/user/repo can be built into the same binary without a symbol clash. Versions v0 and v1 carry no suffix.
The go directive sets the minimum language version your module needs, while toolchain names the specific Go distribution to run, such as go1.24.2. The toolchain directive was introduced in Go 1.21 and is ignored by older releases, so it only makes sense alongside a go line of 1.21 or higher.
It marks a requirement that no package in your module imports directly — it is there because a dependency needs it and its own go.mod did not record the version. Running go mod tidy adds, updates or removes these comments automatically, so you rarely write them by hand.
No. Replace and exclude directives are only honoured in the main module — the one you run the go command in. If your library depends on a fork, consumers will not get the replacement, so publish the fork under its own module path instead.