-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
x/playground: allow selecting supported versions of Go #33629
Comments
Thanks for the proposal.
Go does not break backward compatibility (see https://golang.org/doc/go1compat), so in practice this should not be an issue. A correct piece of code that compiled on go1.5 will still work on a playground that is on go1.13. Forward compatibility is also not really an issue. Yes, you may have some runnable example on The only practical use of a multi-version playground I can imagine is to compare the generated machine code on different Go versions (e.g. to demonstrate better optimizations or show a regression), since that is not stable between releases, and can change; but the playground does not support disassembling anyway (and I think it would be out of scope), moreover you can use godbolt for that (it's literally its point), which already supports all the old Go versions. |
@ALTree Thanks for clarifying backward compatibility promise. I awarded it and that is why I added "Other consideration" with Go 2 paragraph. However, as long as future Go 2 breaks the backward compatibility, the code snippet shared in Go 1 will break. Moreover, another use case for supporting all versions of Go can help Go user exploring bugs of Go. For instance, a code snippet that illustrates a compiler or runtime bug in Go 1.x, but the bug was fixed in Go 1.y (where y > x). Therefore, the code snippet can lose its interpretability of the bug. |
This is true but to be honest it doesn't seem a use-case that compelling. The observation about Go2 is more interesting, and I agree that if a future Go2 breaks backward compatibility then we'll want to have a playground that supports at least 1) the latest/current version and 2) the latest Go1 version. But this is quite different from what you were asking here in the original post (support of every Go1 version). If this is just about a dual Go1/Go2 playground, it seems premature to worry now. cc @andybons |
@ALTree I think there may have some misunderstanding between Go 1.x and Go 2. The reason I keep uses Go 1.x rather than Go 2 in the Proposal section because all announced articles [1, 2, 3], delivers the message that the Go 2 may never be annotated as the official name but arrives in several different releases of Go 1.x, e.g. Go 1.11 for modules, Go 1.13 for errors, Go 1.15 for generics, and so on. This is actually the reason I mentioned in "Other consideration", starting from Go 1.11, "Go is under the transition to Go 2". Basically, I use "Go 1.x" to mix the terminology of Go 1 and Go 2 in the proposal. Towards to have two separate Go1/Go2 playgrounds: if the APIs to Playground is designed well and clean for two incompatible versions of Go, then it is not that difficult to support all versions of Go, isn't it? Unless we arguing support all different versions of Go are wasting server resources. However, this isn't true because VM nowadays scales in seconds upon requests. [1] https://blog.golang.org/toward-go2 |
Now that we can specify the language version in go.mod file and the compiler's -lang flag, it kind of already does: https://play.golang.org/p/B4ARI9cL3A4 |
What you are describing is a lot of work for the Go team, because we run play.golang.org, for diminishing benefit. Actually keeping old versions of software running is non-trivial effort. If someone wanted to run a different site that had all the versions, that'd be great. But the cost-benefit here for the Go team does not seem like it works out. This seems like a likely decline. Leaving open for a week for final comments. |
This comment has been minimized.
This comment has been minimized.
@bradfitz points out that the current playground backends do already support selecting between different compiler trees. Especially given #34536, maybe we should support the last two releases? What's missing is UI to select a specific version. To be clear, this would only be supported versions, not all versions. With that restriction, the burden may be less. We could possibly also add tip, but that would require more work in the backends to refresh tip regularly. It is still unclear who would do the work, but at least limiting the proposal to supported versions would address the ongoing burden. We could accept this and move it to Backlog until someone is interested. |
Change https://golang.org/cl/195983 mentions this issue: |
Sorry, this was meant to go back to Active earlier, not Accepted. |
This creates a VM (running Container-Optimized OS) with configuration such that it boots up and downloads/configures the runsc Docker runtime, reloading the existing Docker daemon on the VM, and then creates a new privileged Docker container with the host's /var/run/docker.sock available to the container. From within that container it's then possible for the new sandbox HTTP server to create its own Docker containers running under gvisor (using docker run --runtime=runsc). This then adds a regional us-central1 load balancer and instance group manager & instane template to run these VMs automatically across us-central1. Then the play.golang.org frontend can hit that URL (http://sandbox.play-sandbox-fwd.il4.us-central1.lb.golang-org.internal) Fixes golang/go#25224 Updates golang/go#30439 (remove nacl) Updates golang/go#33629 (this CL makes the playground support 2 versions) Change-Id: I56c8a86875abcde9d29fa7592b23c0ecd3861458 Reviewed-on: https://go-review.googlesource.com/c/playground/+/195983 Run-TryBot: Brad Fitzpatrick <[email protected]> Reviewed-by: Alexander Rakoczy <[email protected]> Reviewed-by: Emmanuel Odeke <[email protected]>
Based on discussions with @bradfitz, this sounds fairly straightforward to do. This now seems like a likely accept. Leaving open for a week for final comments. |
No change in consensus, so accepted. |
Going in the opposite direction from supporting older versions, how difficult would it be for the Go playground to provide the ability to run Go code using CLs uploaded to Gerrit? E.g., could the trybots automatically build a compiler-tree artifact and store it in GCS somewhere that the Go playground can use (maybe for N days or until the CL is merged or something, to limit storage costs)? I've seen projects that will generate a preview website for each active PR so reviewers can easily see the results. Occasionally, when reviewing compiler CLs, I want to double check that it still handles some cases correctly; currently I'll typically download the CL and build/verify myself, but this is inconvenient sometimes. Also, I like uploading proof-of-concept CLs for language change proposals; it might make it more accessible to non-project-members (folks who aren't used to downloading Gerrit CLs and building locally) if they could experiment with these via the Go playground. If this is at all reasonable, I can file a separate proposal to discuss this further. But if scaling the playground from supporting <10 versions to 100s of versions is going to be technically prohibitive, then I'll leave it be. |
Matthew, the builders already do store the result of make.bash to GCS. Forever. For years now. Unless something changed recently. So probably wouldn't be hard to grab an alternate tarball from the network. |
This comment has been minimized.
This comment has been minimized.
I think it would be enough to support the two latest a |
I realize that I'm a bit late to the discussion, but I had a thought. The Playground has the ability to use remote dependencies, though it seems that it's started printing out |
@DeedleFake that's already possible, an example is selecting the multiple files example |
So it is. I had no clue that that feature had been added. Neat. Thanks. |
I believe this proposal is implemented now and live at https://go.dev/play since golang/website@13fd016. Therefore I am closing this issue. If not, feel free to reopen this again. |
Motivation
Go Playground was introduced in 2010 [1] and provides a great service that not only allows Go users exploring code snippet of Go but also supports all online document examples.
However, the playground only supports the latest version of Go, which may cause an issue: A code snippet was written and shared in Go 1.x. Over time, its shared link may have corrupt running result if Go 1.y (where y > x) introduces forward or backward compatibility issues.
The other example appears in tip.golang.org. The tip.golang.org illustrates the latest beta version of Go, but only uses the latest stable release of Go. If the latest beta contains API changes, the document example will be corrupted. E.g. the example [2] regarding API
errors.As
corrupts in Go 1.13 betas.Proposal
Allow Go Playground support all releases of Go compiler, including beta releases, and
gccgo
. This enables Go users being able to share code snippet with a specific version of Go, as well as powering beta document release in tip.golang.org.Other consideration
Go is under the transition to Go 2, and considerably, future Go versions will introduce more API changes, especially if Generics feature is released (e.g. package sort, container and etc.)
Such a feature allows Go users to share and compare results in different versions.
It is worth mentioning that Compiler Explorer [3] is a famous tool that shows the assembly output of C++ compilers which allow C++ users to explore language changes and performance tunning process. There is already an online version exists [4] which dedicated for Go with few limited supported versions. But this may be an advanced feature that does not need to all Go users.
Services that rely on the Go Playground need to adapt to the changes of Go Playground.
[1] https://blog.golang.org/playground
[2] https://tip.golang.org/pkg/errors/#As
[3] https://godbolt.org/
[4] https://go.godbolt.org/
The text was updated successfully, but these errors were encountered: