A single number, the machine-word integer. string is bytes, not Unicode text. The header of a slice or a map carries its arena, so that the life of the bytes has a name.
Kind Note nilAbsence. Only inhabitant of errorwithout error.booltrue,false.intSigned machine-word integer. Only number. u8Byte. For buffers. stringImmutable bytes, known length. Not Unicode text. errorA value. Compared with ==. Not an exception.struct Value, copied on assignment. *TPointer to a Tliving in a visible arena.[]TSlice: pointer, length, owning arena. map[K]VMap. Same header as the slice. chan[T]Bounded queue. Guard. A name. entree[T]Write end. Copied. Born empty. sortie[T]Read end. Copied. Born empty. interface Pointer to the value, pointer to the vtable. IdIndex in a document table. Not a pointer.
func somme(a, b int) int {
return a + b
}
func main() int {
q := 7 / 2
r := 7 % 2
u := 10 + (0 - 3)
z := 10 + (0 - 7) / 2
return somme(q, r) + u + z
}
/ and % truncate toward zero. -n is the unary. 0 - n is allowed. Operands evaluate left to right.
==requires two values of the same kind.!=,<,>,<=,>=are the signs of C.<,>,<=,>=compare two integers.&&and||short-circuit.
iftakes a boolean. The block runs when it is true.elseis the other block, on the same line as}.else ifchains.
func main() int {
n := 3
if n > 1 {
n = n + 39
}
return n
}
forrepeats the block while the boolean is true. The step is a statement of the body. Nobreak.
for x in xscopies the slice before the first turn.xis the element, a name of the body.for i, x in xsalso binds the index before the element.
x[i]reads.iis anint. The element of a slice has the typeT. The element of a string is au8.len(x)returns anint.
Diagnostic. indice hors table — an index outside 0 .. len-1, including negative.
map[K]Vis a map.Kis anintor astring.m[k]reads.m[k] = vwrites a key already present. An absent key is a host fault. The map does not grow.
x = ycopies the value.xis a variable or a field.x += yisx = x + y. The same family:-=,*=,/=,%=.
p := *Tis the null pointer.*preads.*p = vwrites. Reading or writing the null pointer is the faultpointeur nul.
Diagnostic. pointeur nul — reading or writing the null pointer.
Not in this version. **T, or a pointer to a slice, a map, a string, an error or an interface. No float.