The "Unknown:"s below indicate that an entry is incomplete.
| { ... }(1) | block (grouping statements, especially when statements are not expressions) |
| nothing needed | breaking lines (useful when end-of-line and/or indentation has a special meaning) |
| /* ... */ | commenting (non nestable) |
| // | commenting (until end of line) |
| < > <= >= | comparison |
| strings.Compare() | comparison (returns 3 values (i.e. inferior, equal or superior)) |
| == != | equality / inequality (shallow) |
| runtime.GC() | force garbage collection |
| ( ... ) | grouping expressions |
| runtime.Caller(0) | information about the current line and file |
| case-sensitive | tokens (case-sensitivity (keywords, variable identifiers...)) |
| [_a-zA-Z][_a-zA-Z0-9]* | tokens (variable identifier regexp) |
| CamelCase or camelCase | tokens (what is the standard way for scrunching together multiple words) |
| = | variable assignment or declaration (assignment) |
| := | variable assignment or declaration (both) |
| var v t | variable assignment or declaration (declaration) |
| func(para1 typ1, ...) (typ2, ...) { ... } | anonymous function |
| f(a,b,...) | function call |
| f() | function call (with no parameter) |
| func f(para1 typ1, para2 typ2, ...) (typ3, ...) { ... } | function definition |
| func f(para1 typ1, para2 typ2, ...) { ... } | function definition (procedures) |
| f(args ...typ0)(2) | function definition (variable number of arguments) |
| return(3) | function return value (breaks the control flow) |
| runtime.Caller(0) | runtime inspecting the caller information |
| continue / break | breaking control flow (continue / break) |
| goto | breaking control flow (goto (unconditional jump)) |
| return(3) | breaking control flow (returning a value) |
| recover() | exception (catching) |
| panic(v) | exception (throwing) |
| if c {...} | if_then |
| if c {b1} else if c2 {b2} else {b3} | if_then_else |
| for | loop (for "a la C" (while + initialisation)) |
| for i := 10; i >= 1; i-- {...} | loop (for each value in a numeric range, 1 decrement) |
| for i := 1; i <= 10; i++ {...} | loop (for each value in a numeric range, 1 increment (see also the entries about ranges)) |
| for i := 1; i <= 10; i += 2 {...} | loop (for each value in a numeric range, free increment) |
| for {} | loop (forever loop) |
| for c {...} | loop (while condition do something) |
switch val {
case v1, v2, ...:
...
fallthrough
case v3:
...
default:
...
} | multiple selection (switch) |
| , | sequence |
| ; | sequence |
| var n t | annotation (or variable declaration) |
| (t)(e) | cast (upcast) |
| type n t | declaration |
| const e t | mutability, constness (type of a constant value) |
| mutability is the default | mutability, constness (type of a mutable value) |
| package p | declare |
| Identifier is only exported if the first character of its name is an Unicode upper case letter; and the identifier is declared in the package block or it is a field name or method name. No other identifiers are exported | declare (selective export) |
| import "p" | import (package (ie. load the package)) |
| . | package scope |
| s[n] | accessing n-th character |
| utf8.DecodeRuneInString(s) | ascii to character |
| 'z' | character "z" |
| string(c) | character to ascii |
| rune | character type name |
| string(e) | convert something to a string (see also string interpolation) |
| strings.Repeat | duplicate n times |
| s[n:m+1] | extract a substring |
| strings.Index | locate a substring |
| strings.LastIndex | locate a substring (starting at the end) |
| `...` | multi-line |
| fmt.Print | simple print (on strings) |
| fmt.Printf | simple print (printf-like) |
| fmt.Sprintf | sprintf-like |
| + | string concatenation |
| == !=(Vimscript: whether or not == and != are case-sensitive depends on user settings.) | string equality & inequality |
| len | string size |
| "\n" | strings (end-of-line (without writing the real CR or LF character)) |
| "..." | strings (with no interpolation of variables) |
| string | type name |
| unicode.ToUpper / unicode.ToLower | upper / lower case character |
| strings.ToUpper / strings.ToLower / strings.Title | uppercase / lowercase / capitalized string |
| false | false value |
| ! | logical not |
| || / && | logical or / and (short circuit) |
| true | true value |
| bool | type name |
| append | adding an element at the end (side-effect) |
| l[1:] | all but the first element |
| for i, v := range l {...} | for each element do something |
| for i, v := range l {...} | iterate with index |
| strings.Join | join a list of strings in a string using a glue string |
| l[len(l)-1:] | last element |
| append | list concatenation |
| []t{a, b, c} | list constructor |
| len(l) | list size |
| a[i] | list/array indexing |
| []a | type name |
| h[k] | dictionary (access: read/write) |
| map[typ0]typ1{ a: b, c: d } | dictionary (constructor) |
| v, exists := h[k] | dictionary (has the key ?) |
| delete(h, k) | dictionary (remove by key) |
| map | dictionary (type name) |
| k, v := range h | range (inclusive .. inclusive) |
| . | record (selector) |
| type typ struct{ n1 typ1; n2 typ2; } | record (type declaration) |
| & | reference (pointer) (creation) |
| *(4) | reference (pointer) (dereference) |
| + / - / * / / | addition / subtraction / multiplication / division |
| & / | / ^ | bitwise operators (and / or / xor) |
| << / >> | bitwise operators (left shift / right shift / unsigned right shift) |
| Div(5) | euclidean division (both quotient and modulo) |
| math.Pow | exponentiation (power) |
| math.Log10 | logarithm (base 10) |
| math.Log2 | logarithm (base 2) |
| math.Log | logarithm (base e) |
| % | modulo (modulo of -3 / 2 is -1) |
| - | negation |
| 1000., 1E3 | numbers syntax (floating point) |
| 0xf | numbers syntax (integers in base 2, octal and hexadecimal) |
| 1000 | numbers syntax (integers) |
| mathematical | operator priorities and associativities (addition vs multiplication) |
| rand.Read(6) | random (random number) |
| rand.Seed(7) | random (seed the pseudo random generator) |
| math.Sqrt | square root / e-exponential / absolute value |
| math.Sin / math.Cos / math.Tan | trigonometry (basic) |
| math.Asin / math.Acos / math.Atan | trigonometry (inverse) |
| math.Trunc / / math.Floor / math.Ceil | truncate / round / floor / ceil |
| float32, float64 | type name (floating point) |
| int8, uint8, int16, uint16, ...64 | type name (integers) |
