You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
package main
import"fmt"//go:generate go run golang.org/x/tools/cmd/stringer@latest -type=PilltypePillintconst (
PlaceboPill=iotaAspirinIbuprofenParacetamolAcetaminophen=Paracetamol
)
funcmain() {
fmt.Println(Aspirin.String())
}
$ go generate && go build -o main && ./mainAspirin
The text was updated successfully, but these errors were encountered:
Run on Server - Runs program on original Go Playground servers.
Original Go playground doesn't support go:generate.
Run on Browser - Our API builds a WASM file for you which will be executed on browser.
This also doesn't support running go:generate on build server for security reasons.
Regarding first mode - I suggest creating an issue in go's repo.
Regarding WASM - there is a plan to move Go compiler into a browser. This will resolve potential security concerns but still go:generate support will be limited to only running other Go packages.
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.The text was updated successfully, but these errors were encountered: