gobyexample/public/hello-world
2019-10-15 15:02:01 +03:00

146 lines
4.5 KiB
Plaintext
Generated
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Go в примерах: Hello World</title>
<link rel=stylesheet href="site.css">
</head>
<script>
onkeydown = (e) => {
if (e.key == "ArrowRight") {
window.location.href = 'values';
}
}
</script>
<body>
<div class="example" id="hello-world">
<h2><a href="./">Go в примерах</a>: Hello World</h2>
<table>
<tr>
<td class="docs">
<p>Наша первая программа напечатает классическое сообщение &ldquo;hello world&rdquo;
Полный код.</p>
</td>
<td class="code leading">
<a href="http://play.golang.org/p/r-UD-XLVae8" target="_blank"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" />
<div class="highlight"><pre><span class="kn">package</span> <span class="nx">main</span>
</pre></div>
</td>
</tr>
<tr>
<td class="docs">
</td>
<td class="code leading">
<div class="highlight"><pre><span class="kn">import</span> <span class="s">&quot;fmt&quot;</span>
</pre></div>
</td>
</tr>
<tr>
<td class="docs">
</td>
<td class="code">
<div class="highlight"><pre><span class="kd">func</span> <span class="nx">main</span><span class="p">()</span> <span class="p">{</span>
<span class="nx">fmt</span><span class="p">.</span><span class="nx">Println</span><span class="p">(</span><span class="s">&quot;hello world&quot;</span><span class="p">)</span>
<span class="p">}</span>
</pre></div>
</td>
</tr>
</table>
<table>
<tr>
<td class="docs">
<p>Для запуска программы, добавьте код в файл
<code>hello-world.go</code> и выполните <code>go run</code>.</p>
</td>
<td class="code leading">
<div class="highlight"><pre><span class="gp">$</span> go run hello-world.go
<span class="go">hello world</span>
</pre></div>
</td>
</tr>
<tr>
<td class="docs">
<p>Иногда необходимо собрать программу в бинарный
файл. Мы можем сделать это с помощью команды
<code>go build</code>.</p>
</td>
<td class="code leading">
<div class="highlight"><pre><span class="gp">$</span> go build hello-world.go
<span class="gp">$</span> ls
<span class="go">hello-world hello-world.go</span>
</pre></div>
</td>
</tr>
<tr>
<td class="docs">
<p>Мы можем выполнить бинарный файл напрямую.</p>
</td>
<td class="code leading">
<div class="highlight"><pre><span class="gp">$</span> ./hello-world
<span class="go">hello world</span>
</pre></div>
</td>
</tr>
<tr>
<td class="docs">
<p>Теперь когда мы можем запускать и собирать Go-программы,
давайте узнаем больше об этом языке.</p>
</td>
<td class="code empty">
</td>
</tr>
</table>
<p class="next">
Следующий пример: <a href="values">Типы данных (Values)</a>.
</p>
<p class="footer">
by <a href="https://markmcgranaghan.com">Mark McGranaghan</a> | <a href="https://github.com/mmcgrana/gobyexample/blob/master/examples/hello-world">source</a> | <a href="https://github.com/mmcgrana/gobyexample#license">license</a>
<br/>
переведено Nick S. | <a href="https://github.com/badkaktus/gobyexample">исходники</a>
</p>
</div>
<script>
var codeLines = [];
codeLines.push('package main\u000A');codeLines.push('import \"fmt\"\u000A');codeLines.push('func main() {\u000A fmt.Println(\"hello world\")\u000A}\u000A');codeLines.push('');codeLines.push('');codeLines.push('');codeLines.push('');
</script>
<script src="site.js" async></script>
</body>
</html>