From: Rob Pike Date: Wed, 18 Feb 2009 23:39:51 +0000 (-0800) Subject: First piece of Go reference manual. X-Git-Tag: weekly.2009-11-06~2154 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=d1107adb522c387dbcad07493f9d80b72c3642d0;p=gostls13.git First piece of Go reference manual. R=ken,gri,rsc DELTA=185 (185 added, 0 deleted, 0 changed) OCL=25133 CL=25169 --- diff --git a/doc/go_ref.html b/doc/go_ref.html new file mode 100644 index 0000000000..8e020bfa9d --- /dev/null +++ b/doc/go_ref.html @@ -0,0 +1,93 @@ + +

Introduction

+ +

+This is a reference manual for the Go programming language. For more information and other documents, see the Go home page. +

+ +

+Go is a general-purpose language designed with systems programming in mind. It is strongly typed and garbage-collected, and has explicit support for concurrent programming. Programs are constructed from packages, whose properties allow efficient management of dependencies. The existing implementations use a traditional compile/link model to generate executable binaries. +

+ +

+The grammar is simple and regular, allowing for easy analysis by automatic tools such as integrated development environments. +

+ +

Lexical properties

+ +

+A program is constructed from a set of packages. Each package is defined by one or more source files compiled separately. In processing the source text in each file, the input is divided into a sequence of tokens. +

+ +

Unicode text

+ +

+Go source text is a sequence of Unicode code points encoded in UTF-8. The language processor does not canonicalize the input, so it will treat a single accented code point as distinct from the same character constructed from combining an accent and a letter; those are treated as two code points. For simplicity, this document will use the term character to refer to a Unicode code point. +

+

+Each code point is distinct; for example, upper and lower case letters are different characters. +

+ +

Tokens

+ +

+There are four classes of tokens: identifiers, keywords, operators and delimiters, and literals. White space, formed from blanks, tabs, and newlines, is ignored except as it separates tokens that would otherwise combine into a single token. Comments, defined below, behave as white space. While breaking the input into tokens, the next token is the longest sequence of characters that form a valid token. +

+ +

Comments

+ +

+There are two forms of comments. The first starts at a the character sequence // and continues through the next newline. The second starts at the character sequence /* and continues through the character sequence */. Comments do not nest. +

+ +

Identifiers

+ +

+An identifier is a sequence of one or more letters and digits. The meaning of letter and digit is defined by the Unicode properties for the corresponding characters, with the addition that the underscore character _ (U+005F) is considered a letter. The first character in an identifier must be a letter. (Current implementation accepts only ASCII digits for digits.) +

+ +

Keywords

+ +

+The following keywords are reserved and may not be used as identifiers. +

+
+break        default      func         interface    select
+case         defer        go           map          struct
+chan         else         goto         package      switch
+const        fallthrough  if           range        type
+continue     for          import       return       var
+
+ +

Operators and Delimiters

+ +

+The following character sequences are tokens representing operators, delimiters, and other special lexemes: +

+
++    &     +=    &=     &&    ==    !=    (    )
+-    |     -=    |=     ||    <     <=    [    ]
+*    ^     *=    ^=     <-    >     >=    {    }
+/    <<    /=    <<=    ++    =     :=    ,    ;
+%    >>    %=    >>=    --    !     ...   .    :
+
+ +

Literals

+ +

Integer literals

+ +

Floating-point literals

+ +

Character literals

+ +

String literals

+ + + + +
+ + +