Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support //go:generate #353

Open
lesiw opened this issue Jul 4, 2024 · 2 comments
Open

Support //go:generate #353

lesiw opened this issue Jul 4, 2024 · 2 comments
Labels
awaiting-feedback Requires feedback from one or other users enhancement New feature or request

Comments

@lesiw
Copy link

lesiw commented Jul 4, 2024

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
Copy link

This issue is stale because it has been open for 15 days with no activity. It will be closed if no further activity occurs. Thank you.

@github-actions github-actions bot added the stale label Jul 20, 2024
@x1unix
Copy link
Owner

x1unix commented Aug 2, 2024

So at the moment, Playground offers two modes:

  • 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.

@x1unix x1unix added enhancement New feature or request awaiting-feedback Requires feedback from one or other users and removed stale labels Aug 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-feedback Requires feedback from one or other users enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants