|
| 1 | +<!--{ |
| 2 | + "Path": "/", |
| 3 | + "Template": true |
| 4 | +}--> |
| 5 | + |
| 6 | +<div class="left"> |
| 7 | + |
| 8 | +<div id="learn"> |
| 9 | +{{if not $.GoogleCN}} |
| 10 | +<a class="popout share">Pop-out</a> |
| 11 | +{{end}} |
| 12 | +<div class="rootHeading">Try Go</div> |
| 13 | +<div class="input"> |
| 14 | +<textarea spellcheck="false" class="code">// You can edit this code! |
| 15 | +// Click here and start typing. |
| 16 | +package main |
| 17 | + |
| 18 | +import "fmt" |
| 19 | + |
| 20 | +func main() { |
| 21 | + fmt.Println("Hello, 世界") |
| 22 | +}</textarea> |
| 23 | +</div> |
| 24 | +<div class="output"> |
| 25 | +<pre> |
| 26 | +Hello, 世界 |
| 27 | +</pre> |
| 28 | +</div> |
| 29 | +<div class="buttons"> |
| 30 | +<a class="run" href="#" title="Run this code [shift-enter]">Run</a> |
| 31 | +{{if not $.GoogleCN}} |
| 32 | +<a class="share" href="#" title="Share this code">Share</a> |
| 33 | +<a class="tour" href="//tour.golang.org/" title="Learn Go from your browser">Tour</a> |
| 34 | +{{end}} |
| 35 | +</div> |
| 36 | +<div class="toys"> |
| 37 | +<select> |
| 38 | + <option value="hello.go">Hello, World!</option> |
| 39 | + <option value="life.go">Conway's Game of Life</option> |
| 40 | + <option value="fib.go">Fibonacci Closure</option> |
| 41 | + <option value="peano.go">Peano Integers</option> |
| 42 | + <option value="pi.go">Concurrent pi</option> |
| 43 | + <option value="sieve.go">Concurrent Prime Sieve</option> |
| 44 | + <option value="solitaire.go">Peg Solitaire Solver</option> |
| 45 | + <option value="tree.go">Tree Comparison</option> |
| 46 | +</select> |
| 47 | +</div> |
| 48 | +</div> |
| 49 | + |
| 50 | +</div> |
| 51 | + |
| 52 | +<div class="right"> |
| 53 | + |
| 54 | +<div id="about"> |
| 55 | +Go is an open source programming language that makes it easy to build |
| 56 | +simple, reliable, and efficient software. |
| 57 | +</div> |
| 58 | + |
| 59 | +<div id="gopher"></div> |
| 60 | + |
| 61 | +<a href="/dl/" id="start"> |
| 62 | +<span class="big">Download Go</span> |
| 63 | +<span class="desc"> |
| 64 | +Binary distributions available for<br> |
| 65 | +Linux, macOS, Windows, and more. |
| 66 | +</span> |
| 67 | +</a> |
| 68 | + |
| 69 | +</div> |
| 70 | + |
| 71 | +<div style="clear: both"></div> |
| 72 | + |
| 73 | +{{if not $.GoogleCN}} |
| 74 | +<div class="left"> |
| 75 | + <div id="video"> |
| 76 | + <div class="rootHeading">Featured video</div> |
| 77 | + <div class="js-frontpage-video" style="--aspect-ratio-padding: 58.07%;"><iframe width="415" height="241" src="//www.youtube.com/embed/ytEkHepK08c" frameborder="0" allowfullscreen></iframe></div> |
| 78 | + </div> |
| 79 | +</div> |
| 80 | + |
| 81 | +<div class="right"> |
| 82 | + <div id="blog"> |
| 83 | + <div class="rootHeading">Featured articles</div> |
| 84 | + <div class="read"><a href="//blog.golang.org/">Read more</a></div> |
| 85 | + </div> |
| 86 | +</div> |
| 87 | +{{end}} |
| 88 | + |
| 89 | +<div style="clear: both;"></div> |
| 90 | + |
| 91 | +<script> |
| 92 | +(function() { |
| 93 | + 'use strict'; |
| 94 | + |
| 95 | + window.initFuncs.push(function() { |
| 96 | + // Set up playground if enabled. |
| 97 | + if (window.playground) { |
| 98 | + window.playground({ |
| 99 | + "codeEl": "#learn .code", |
| 100 | + "outputEl": "#learn .output", |
| 101 | + "runEl": "#learn .run", |
| 102 | + "shareEl": "#learn .share", |
| 103 | + "shareRedirect": "//play.golang.org/p/", |
| 104 | + "toysEl": "#learn .toys select" |
| 105 | + }); |
| 106 | + } else { |
| 107 | + $('#learn').hide() |
| 108 | + } |
| 109 | + }); |
| 110 | + |
| 111 | + {{if not $.GoogleCN}} |
| 112 | + |
| 113 | + function readableTime(t) { |
| 114 | + var m = ["January", "February", "March", "April", "May", "June", "July", |
| 115 | + "August", "September", "October", "November", "December"]; |
| 116 | + var p = t.substring(0, t.indexOf("T")).split("-"); |
| 117 | + var d = new Date(p[0], p[1]-1, p[2]); |
| 118 | + return d.getDate() + " " + m[d.getMonth()] + " " + d.getFullYear(); |
| 119 | + } |
| 120 | + |
| 121 | + window.feedLoaded = function(result) { |
| 122 | + var blog = document.getElementById("blog"); |
| 123 | + var read = blog.getElementsByClassName("read")[0]; |
| 124 | + for (var i = 0; i < result.length && i < 2; i++) { |
| 125 | + var entry = result[i]; |
| 126 | + var title = document.createElement("a"); |
| 127 | + title.className = "title"; |
| 128 | + title.href = entry.Link; |
| 129 | + title.innerHTML = entry.Title; |
| 130 | + blog.insertBefore(title, read); |
| 131 | + var extract = document.createElement("div"); |
| 132 | + extract.className = "extract"; |
| 133 | + extract.innerHTML = entry.Summary; |
| 134 | + blog.insertBefore(extract, read); |
| 135 | + var when = document.createElement("div"); |
| 136 | + when.className = "when"; |
| 137 | + when.innerHTML = "Published " + readableTime(entry.Time); |
| 138 | + blog.insertBefore(when, read); |
| 139 | + } |
| 140 | + } |
| 141 | + |
| 142 | + window.initFuncs.push(function() { |
| 143 | + // Load blog feed. |
| 144 | + $('<script/>').attr('text', 'text/javascript') |
| 145 | + .attr('src', '//blog.golang.org/.json?jsonp=feedLoaded') |
| 146 | + .appendTo('body'); |
| 147 | + |
| 148 | + // Set the video at random. |
| 149 | + var videos = [ |
| 150 | + {h: 241, s: "//www.youtube.com/embed/ytEkHepK08c"}, // Tour of Go |
| 151 | + {h: 241, s: "//www.youtube.com/embed/f6kdp27TYZs"}, // Concurrency Patterns |
| 152 | + {h: 233, s: "//player.vimeo.com/video/69237265"} // Simple environment |
| 153 | + ]; |
| 154 | + var v = videos[Math.floor(Math.random()*videos.length)]; |
| 155 | + $('#video iframe').attr('height', v.h).attr('src', v.s); |
| 156 | + // Compute the aspect ratio (as a percentage) of the video |
| 157 | + // using the fixed width 415 and the height of the current video, v.h. |
| 158 | + var ar = 100*v.h/415; |
| 159 | + $('.js-frontpage-video').attr('style', '--aspect-ratio-padding: ' + ar + '%;'); |
| 160 | + }); |
| 161 | + |
| 162 | + {{end}} |
| 163 | +})(); |
| 164 | +</script> |
0 commit comments