Язык программирования Go

google, “A Tutorial for the Go Programming Language”, public translation into Russian from English More about this translation.

Translate into another language.

Participants

kron0s711 points
curly_mary289 points
Kroxy184 points
And others...
Join Translated.by to translate! If you already have a Translated.by account, please sign in.
If you do not want to register an account, you can sign in with OpenID.
Pages: ← previous Ctrl next next untranslated

A Tutorial for the Go Programming Language

Язык программирования Go

Unapproved edits (Latest: kron0s 2 years, 5 months ago) §

Introduction

Введение

History of edits (Latest: kron0s 2 years, 5 months ago) §

Hello, World

Hello, World

History of edits (Latest: kron0s 2 years, 5 months ago) §

Compiling

Компиляция

History of edits (Latest: kron0s 2 years, 5 months ago) §

Echo

Echo

History of edits (Latest: Kroxy 2 years, 3 months ago) §

An Interlude about Types

Немного о типах

History of edits (Latest: kron0s 2 years, 5 months ago) §

An Interlude about Allocation

Немного о выделении памяти

History of edits (Latest: kron0s 2 years, 5 months ago) §

An Interlude about Constants

Немного о константах

History of edits (Latest: kron0s 2 years, 5 months ago) §

An I/O Package

Ввод/вывод

History of edits (Latest: kron0s 2 years, 5 months ago) §

Rotting cats

Sorting

Сортировка

History of edits (Latest: kron0s 2 years, 5 months ago) §

Printing

Форматированный вывод

History of edits (Latest: kron0s 2 years, 5 months ago) §

Prime numbers

Простые числа

History of edits (Latest: Wio 2 years, 5 months ago) §

Multiplexing

Мультиплексирование

History of edits (Latest: Wio 2 years, 5 months ago) §

Introduction[Top]

Введение

History of edits (Latest: kron0s 2 years, 5 months ago) §

This document is a tutorial introduction to the basics of the Go programming language, intended for programmers familiar with C or C++. It is not a comprehensive guide to the language; at the moment the document closest to that is the language specification. After you've read this tutorial, you might want to look at Effective Go, which digs deeper into how the language is used. Also, slides from a 3-day course about Go are available: Day 1, Day 2, Day 3.

В этом документе изложенны основы языка Go для программистов знакомых с С и С++. Это не исчерпывающее описание языка, некоторые моменты подробно описаны в спецификации. После прочтения этого обзора, возможно вам будет интересно ознакомиться с Effective Go, в котором более подробно описано, как используется язык. Так же есть слайды 3-дневного курса Go: день 1, день 2 и день 3.

History of edits (Latest: kron0s 2 years, 5 months ago) §

The presentation here proceeds through a series of modest programs to illustrate key features of the language. All the programs work (at time of writing) and are checked into the repository in the directory /doc/progs/.

Изложенный материал продолжает серия небольших программ для иллюстрации ключевых возможностей языка. Все программы работоспособны (на момент написания) и расположены в хранилище в директории /doc/progs/.

History of edits (Latest: Wio 2 years, 5 months ago) §

Program snippets are annotated with the line number in the original file; for cleanliness, blank lines remain blank.

Отрывки программ снабжены номером строки в оригинальном файле; для чистоты, пустые строчки остаются пустыми.

History of edits (Latest: Kroxy 2 years, 3 months ago) §

Hello, World[Top]

Привет, Мир

Unapproved edits (Latest: kron0s 2 years, 5 months ago) §

Let's start in the usual way:

Начнем, как это обычно делается:

History of edits (Latest: kron0s 2 years, 5 months ago) §

05 package main

05 package main

History of edits (Latest: kron0s 2 years, 5 months ago) §

07 import fmt "fmt" // Package implementing formatted I/O.

07 import fmt "fmt" // пакет отвечающий за форматированный ввод/вывод

History of edits (Latest: kron0s 2 years, 5 months ago) §

09 func main() { 10 fmt.Printf("Hello, world; or Καλημέρα κόσμε; or こんにちは 世界\n"); 11 }

09 func main() { 10 fmt.Printf("Привет, мир!; or Καλημέρα κόσμε; or こんにちは 世界\n"); 11 }

History of edits (Latest: kron0s 2 years, 5 months ago) §

Every Go source file declares, using a package statement, which package it's part of. It may also import other packages to use their facilities. This program imports the package fmt to gain access to our old, now capitalized and package-qualified, friend, fmt.Printf.

Каждый входной файл в Go объявляется с использованием пакетного оператора, частью которого является пакет. Можно также импортировать другие пакеты для использования их функционала.

History of edits (Latest: curly_mary 2 years, 3 months ago) §

Functions are introduced with the func keyword. The main package's main function is where the program starts running (after any initialization).

Функции объявляются с ключевым словом func. Программа начинает выполняться с функции main основного пакета (после инициализации).

History of edits (Latest: kron0s 2 years, 5 months ago) §

String constants can contain Unicode characters, encoded in UTF-8. (In fact, Go source files are defined to be encoded in UTF-8.)

Строки могут содержать Unicode символ в UTF-8. (В действительности, исходные файлы Go кодированны в UTF-8.)

History of edits (Latest: kron0s 2 years, 5 months ago) §

The comment convention is the same as in C++:

Комментарии используются так же как и в С++:

History of edits (Latest: kron0s 2 years, 5 months ago) §

/* ... */

/* ... */

History of edits (Latest: kron0s 2 years, 5 months ago) §

// ...

// ...

History of edits (Latest: kron0s 2 years, 5 months ago) §

Later we'll have much more to say about printing.

Позже мы много скажем о выводе на экран.

History of edits (Latest: kron0s 2 years, 5 months ago) §

Compiling[Top]

Компиляция

History of edits (Latest: kron0s 2 years, 5 months ago) §

Go is a compiled language. At the moment there are two compilers. Gccgo is a Go compiler that uses the GCC back end. There is also a suite of compilers with different (and odd) names for each architecture: 6g for the 64-bit x86, 8g for the 32-bit x86, and more. These compilers run significantly faster but generate less efficient code than gccgo. At the time of writing (late 2009), they also have a more robust run-time system although gccgo is catching up.

Go - компилируемый язык. На текущий момент есть два компилятора. Gccgo - Go компилятор использующий GCC. Есть так же серия компиляторов с разными (и странными) именами для каждой архитектуры процессора: 6g для 64-битных, 8g для 84-битных, и так далее. Эти компиляторы значительно быстрее, но генерируют менее эффективный код чем gccgo. На данный момент (конец 2009 года), они также имеют более оптимизированную систему реального времени, хотя gccgo догоняет их.

History of edits (Latest: kron0s 2 years, 5 months ago) §
Pages: ← previous Ctrl next next untranslated

© google.