blob: 60174632af1ef35ceb9381040dab9d01783117dd [file] [log] [blame]
<!doctype html>
<html>
<head>
<title>Go Playground</title>
<link rel="stylesheet" href="/static/style.css">
<script src="//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>
$(document).ready(function() {
playground({
'codeEl': '#code',
'outputEl': '#output',
'runEl': '#run',
'fmtEl': '#fmt',
'fmtImportEl': '#imports',
'shareEl': '#share',
'shareURLEl': '#shareURL',
'enableHistory': true
});
$('#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' : '');
});
});
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">
<div id="banner">
<div id="head" itemprop="name">Go Playground</div>
<div id="controls">
<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>
<input type="button" value="Share" id="share">
<input type="text" id="shareURL">
</div>
<div id="aboutControls">
<input type="button" value="About" id="aboutButton">
</div>
</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 Go Playground is a web service that runs on
<a href="//golang.org/">golang.org</a>'s servers.
The service receives a Go program, compiles, links, and
runs the program inside a sandbox, then returns the output.
</p>
<p>
There are limitations to the programs that can be run in the playground:
</p>
<ul>
<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 article "<a href="//blog.golang.org/playground" target="_blank">Inside
the Go Playground</a>" describes how the playground is implemented.
</p>
<p>
The playground uses the latest stable release of Go.<br>
To find the precise version, run <a href="/p/1VcPUlPk_3">this program</a>.
</p>
<p>
The playground service is used by more than just the official Go project
(<a href="//gobyexample.com/">Go by Example</a> is one other instance)
and we are happy for you to use it on your own site.
All we ask is that you <a href="mailto:golang-dev@googlegroups.com">contact us first</a>,
use a unique user agent in your requests (so we can identify you),
and that your service is of benefit to the Go community.
</p>
</div>
</body>
</html>