blob: 3d5febc7366882817af835841f22d0a6c8b3661c [file] [log] [blame]
<!doctype html>
<html>
<head>
<title>The go2go Playground</title>
<link rel="stylesheet" href="/static/style.css">
{{if .Analytics}}
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-11222381-7"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-11222381-7');
gtag('config', 'UA-49880327-6');
</script>
{{end}}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script src="/static/jquery-linedtextarea.js"></script>
<script src="/playground.js"></script>
<script src="/static/playground-embed.js"></script>
<script>
$(document).ready(function() {
playground({
'codeEl': '#code',
'outputEl': '#output',
'runEl': '#run, #embedRun',
'fmtEl': '#fmt',
'fmtImportEl': '#imports',
{{if $.Share}}
'shareEl': '#share',
'shareURLEl': '#shareURL',
{{end}}
'enableHistory': true,
'enableShortcuts': true,
'enableVet': true,
'toysEl': '.js-playgroundToysEl'
});
playgroundEmbed({
'codeEl': '#code',
{{if $.Share}}
'shareEl': '#share',
{{end}}
'embedEl': '#embed',
'embedLabelEl': '#embedLabel',
'embedHTMLEl': '#shareURL'
});
$('#code').linedtextarea();
// Avoid line wrapping.
$('#code').attr('wrap', 'off');
var about = $('#about');
about.click(function(e) {
if ($(e.target).is('a')) {
return;
}
about.hide();
});
$('#aboutButton').click(function() {
if (about.is(':visible')) {
about.hide();
return;
}
about.show();
})
// Preserve "Imports" checkbox value between sessions.
if (readCookie('playgroundImports') == 'true') {
$('#imports').attr('checked','checked');
}
$('#imports').change(function() {
createCookie('playgroundImports', $(this).is(':checked') ? 'true' : '');
});
{{if .Analytics}}
// Fire Google Analytics events for Run/Share button clicks.
$('#run').click(function() {
gtag('event', 'click', {
event_category: 'playground',
event_label: 'run-button',
});
});
$('#share').click(function() {
gtag('event', 'click', {
event_category: 'playground',
event_label: 'share-button',
});
});
{{end}}
});
function createCookie(name, value) {
document.cookie = name+"="+value+"; path=/";
}
function readCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
}
</script>
</head>
<body itemscope itemtype="http://schema.org/CreativeWork">
<input type="button" value="Run" id="embedRun">
<div id="banner">
<div id="head" itemprop="name">
The
<a href="https://blog.golang.org/generics-next-step">go2go</a>
Playground
</div>
<input type="button" value="Run" id="run">
<input type="button" value="Format" id="fmt">
<div id="importsBox">
<label title="Rewrite imports on Format">
<input type="checkbox" id="imports">
Imports
</label>
</div>
{{if $.Share}}
<input type="button" value="Share" id="share">
<input type="text" id="shareURL">
<label id="embedLabel">
<input type="checkbox" id="embed">
embed
</label>
{{end}}
<select class="js-playgroundToysEl">
<option value="hello.txt">Hello, playground</option>
<option value="min.txt">Min function</option>
<option value="queue.txt">Basic queue</option>
</select>
<input type="button" value="About" id="aboutButton">
</div>
<div id="wrap">
<textarea itemprop="description" id="code" name="code" autocorrect="off" autocomplete="off" autocapitalize="off" spellcheck="false">{{printf "%s" .Snippet.Body}}</textarea>
</div>
<div id="output"></div>
<img itemprop="image" src="/static/gopher.png" style="display:none">
<div id="about">
<p><b>About the Playground</b></p>
<p>
The go2go Playground is a web service that runs on
<a href="https://golang.org/">golang.org</a>'s servers.
The service receives a Go program, <a href="https://golang.org/cmd/vet/">vets</a>, compiles, links, and
runs the program inside a sandbox, then returns the output.
</p>
<p>
<b>
This experimental instance of the playground supports the syntax described in the
<a href="https://go.googlesource.com/proposal/+/refs/heads/master/design/go2draft-type-parameters.md">Type Parameters design draft</a>,
utilizing the
<a href="https://go.googlesource.com/go/+/refs/heads/dev.go2go/README.go2go.md">go2go tool</a>.
</b>
</p>
<p>
The best way to provide feedback for the language changes will be on the mailing list golang-nuts@googlegroups.com.
Mailing lists are imperfect, but they seem like our best option for initial discussion.
When writing about the design draft, please put [generics] at the start of the Subject line and to start different
threads for different specific topics.
</p>
<p>
If you find bugs in the generics type checker, the translation tool, or this playground instance they should be
filed in the standard Go issue tracker at <a href="https://golang.org/issue/new?title=cmd%2Fgo2go%3A">https://golang.org/issue</a>.
Please start the issue title with cmd/go2go:. Note that the issue tracker is not the best place to discuss
changes to the language, because it does not provide threading and it is not well suited to lengthy conversations.
</p>
<p>
We look forward to your feedback.
</p>
<p>
There are limitations to the programs that can be run in the playground:
</p>
<ul>
<li>
Not all features of the normal playground are supported.
<a href="https://golang.org/issue/39675">This issue</a> tracks feature parity with play.golang.org.
</li>
<li>
The playground can use most of the standard library, with some exceptions.
The only communication a playground program has to the outside world
is by writing to standard output and standard error.
</li>
<li>
In the playground the time begins at 2009-11-10 23:00:00 UTC
(determining the significance of this date is an exercise for the reader).
This makes it easier to cache programs by giving them deterministic output.
</li>
<li>
There are also limits on execution time and on CPU and memory usage.
</li>
</ul>
<p>
The source code is available at <a href="https://go.googlesource.com/playground/+/refs/heads/dev.go2go" target="_blank" rel="noopener">
https://go.googlesource.com/playground/+/refs/heads/dev.go2go</a>.
</p>
<p>
Any requests for content removal should be directed to
<a href="mailto:security@golang.org">security@golang.org</a>.
Please include the URL and the reason for the request.
</p>
</div>
</body>
</html>