Introduction
This is the reference manual for the Go programming language. 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 syntax is compact and simple to parse, allowing for easy analysis by automatic tools such as integrated development environments.The Go language specification covers language version go1.26 (January 12, 2026). For the complete specification, see go.dev/ref/spec.
Notation
The syntax is specified using a variant of Extended Backus-Naur Form (EBNF):Lowercase production names are used to identify lexical (terminal) tokens. Non-terminals are in CamelCase. Lexical tokens are enclosed in double quotes
"" or back quotes “.Source Code Representation
Source code is Unicode text encoded in UTF-8. The text is not canonicalized, so a single accented code point is distinct from the same character constructed from combining an accent and a letter; those are treated as two code points. Each code point is distinct; for instance, uppercase and lowercase letters are different characters.Characters
The following terms denote specific Unicode character categories:Letters and Digits
The underscore character_ (U+005F) is considered a lowercase letter.
Lexical Elements
Comments
Comments serve as program documentation. There are two forms:
A comment cannot start inside a rune or string literal, or inside a comment. A general comment containing no newlines acts like a space. Any other comment acts like a newline.
Semicolons
The formal syntax uses semicolons; as terminators in a number of productions. Go programs may omit most of these semicolons using automatic insertion rules:
-
When the input is broken into tokens, a semicolon is automatically inserted into the token stream immediately after a line’s final token if that token is:
- An identifier
- An integer, floating-point, imaginary, rune, or string literal
- One of the keywords
break,continue,fallthrough, orreturn - One of the operators and punctuation
++,--,),], or}
-
To allow complex statements to occupy a single line, a semicolon may be omitted before a closing
)or}.
Keywords
The following keywords are reserved and may not be used as identifiers:Types
A type determines a set of values together with operations and methods specific to those values. A type may be denoted by a type name, if it has one, which must be followed by type arguments if the type is generic. A type may also be specified using a type literal, which composes a type from existing types.Boolean Types
A boolean type represents the set of Boolean truth values denoted by the predeclared constantstrue and false. The predeclared boolean type is bool.
Numeric Types
Go provides several predeclared architecture-independent numeric types:- Unsigned integers
- Signed integers
- Floating-point
- Complex
The
byte type is an alias for uint8, and rune is an alias for int32.String Types
A string type represents the set of string values. A string value is a (possibly empty) sequence of bytes. Strings are immutable: once created, it is impossible to change the contents of a string.Key Language Features
Packages
Programs are constructed from packages, which offer dependency management and encapsulation.
Goroutines
Lightweight concurrent execution with explicit support for concurrent programming.
Channels
Type-safe message passing for synchronization between goroutines.
Interfaces
Implicit satisfaction enabling flexible polymorphism.
Main Specification Sections
The complete Go language specification covers these major topics:Constants and Variables
Constants and Variables
Defines constant and variable declarations, including typed and untyped constants, and variable initialization.
Expressions
Expressions
Covers operands, operators, conversions, method calls, and evaluation order.
Statements
Statements
Documents control flow statements including if, for, switch, select, and defer.
Built-in Functions
Built-in Functions
Describes predeclared functions like
make, new, len, cap, append, and panic.Program Initialization
Program Initialization
Explains package initialization, import statements, and the execution of
init functions.Related Resources
Effective Go
Best practices and idiomatic Go programming patterns
Memory Model
Understanding Go’s memory consistency guarantees
GODEBUG
Backwards compatibility and GODEBUG settings