-
-
Notifications
You must be signed in to change notification settings - Fork 88
Open
Labels
enhancementNew feature or requestNew feature or request
Description
One of the limitations of the original Go Playground is that //go:generate
directives are not evaluated before program execution. It might be useful to have a playground that permits experimentation with generated code.
Here's an example of a program using the stringer
package, as demonstrated in the original blog post announcing go:generate.
package main
import "fmt"
//go:generate go run golang.org/x/tools/cmd/stringer@latest -type=Pill
type Pill int
const (
Placebo Pill = iota
Aspirin
Ibuprofen
Paracetamol
Acetaminophen = Paracetamol
)
func main() {
fmt.Println(Aspirin.String())
}
$ go generate && go build -o main && ./main
Aspirin
travisbhartwell
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request