Repository navigation
Move gomods example to the go tool directive - #127
Merged
Merged
Conversation
The example still used go 1.12 and told readers to go get -u enumer, generate, then go mod tidy to drop it again. With Go 1.25 required anyway, pin enumer with a tool directive so go generate works on a fresh clone and tidy keeps the dependency. - examples/gomods/go.mod: go 1.25, tool github.com/dmarkham/enumer - examples/gomods/main.go: go:generate go tool enumer - examples/gomods/README.md: new steps - README.md: state the Go 1.25 floor and lead the install section with the tool directive, pointing at the example - README.md: remove the retired Go Report Card badge
dmarkham
force-pushed
the
example-go-tool
branch
from
October 3, 2026 07:04
2082041 to
3bcc9f5
Compare
This was referenced Oct 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The
examples/gomodsmodule still declaredgo 1.12and its README told readers togo get -uenumer, generate, thengo mod tidyto remove it again. Since enumer now requires Go 1.25, the example pins enumer with atooldirective instead.go generateworks on a fresh clone andgo mod tidykeeps the dependency.Changes
examples/gomods/go.mod:go 1.25.0,tool github.com/dmarkham/enumer, matchinggo.sumexamples/gomods/main.go://go:generate go tool enumer -type=Pill -jsonexamples/gomods/README.md: rewritten stepsREADME.md: states the Go 1.25 floor, leads the install section with the tool directive, and points at the example as a runnable module set up that wayVerification
In the example directory:
go mod tidyis stable,go generatewritespill_enumer.go,go run .prints the expected three lines, and deleting the generated file and regenerating works again.