go:generate in Go
A comment that records the command which regenerates a file.
package state
//go:generate stringer -type=State -output=state_string.go
// State is where a tour step stands for one player.
type State int
const (
// Locked means an earlier step still needs a star.
Locked State = iota
// Open means it can be played.
Open
// Cleared means it has at least one star.
Cleared
)
How it works
go generate ./...runs every directive it finds.- It is never run by
go build: generation is deliberate. - Commit the generated file, and say where it came from.
Keywords and builtins used here
constinttype
The run, in numbers
- Lines
- 15
- Characters to type
- 313
- Tokens
- 19
- Three-star pace
- 105 tpm
At the three-star pace of 105 tokens a minute, this run takes about 11 seconds.
Step 5 of 5 in Packages & build, step 25 of 26 in Standard library & project layout.