Title: Theory / Unimportant / CS / Programming / Golang / Tour/
Tags: FromInstruction computer_to_instruction declaration todo_declaration hasNotNewEffectReturnsMeaning automatedNewLineAfterCommaSpace type FromVariables
On every note of this deck, unless a note says otherwise:
Language: go

Variable: main
Meaning: The name of the package executed first
Page: https://tour.golang.org/basics/1
Context: Golang
Language: go

Instruction: func foo(
  bar_1 plop_1,
  ...,
  bar_m _ plop_m
) gloup{
miam
}
Page: https://tour.golang.org/basics/1
Meaning: Create a function named foo with parameters bar_i of type plop_i,
  returning a value of type group. Its body is miam
Language: go
Context: Golang

Instruction: Adding a list (
  bar_1' plop_1',
  ...,
  bar_m' _ plop_m'
) between the list of arguments and {
Page: https://tour.golang.org/basics/1
Effect: Introduce variables bar_i' of type plop_i'. Those variables are the one returned by an empty return in the function
Context: Golang

Instruction: import(
miam_1
...
miam_n
)
Page: https://tour.golang.org/basics/1
Effect: Import the packages with import path miam_i
Context: Golang

Instruction: package foo
Page: https://tour.golang.org/basics/1
Effect: state that we are defining package foo
Context: Golang

Instruction: name starting with a capital letter
Page: https://tour.golang.org/basics/1
Effect: a name exported
Context: Golang

Instruction: name starting with a lower letter
Page: https://tour.golang.org/basics/1
Effect: a name not exported
Context: Golang

Name: Exported name
Definition: A name which can be used outside from its package of definition
Page: https://tour.golang.org/basics/3
Context: go

Name: Naked return
Definition: A return not accompagnied by a returned value
Page: https://tour.golang.org/basics/7
Context: Golang

Instruction: return
Page: https://tour.golang.org/basics/7
Effect: return the named return value
Context: Golang

Instruction: var foo bar
Page: https://tour.golang.org/basics/7
Meaning: Introduce a variable foo of type bar, with initial value 0/false/""
Language: go
Context: Golang

Instruction: var foo=bar
Page: https://tour.golang.org/basics/7
Meaning: Introduce a variable foo, with initial value bar and type the type of bar
Language: go
Context: Golang
Abbreviation: foo:=bar (only in functions)

Instruction: var foo plop=bar
Page: https://tour.golang.org/basics/7
Meaning: Introduce a variable foo, with initial value bar and type plop
Language: go
Context: Golang

Name: Basic type
Definition: bool
Page: https://tour.golang.org/basics/11
Context: Go
Definition2: string
Definition3: int and int-related
Definition4: rune
Definition5: float related number
Definition6: complex-related number

Instruction: t(x)
Page: https://tour.golang.org/basics/13
Effect: Convert value x to type t
Context: Golang
Variables: t a type
x a term

Instruction: const foo = bar
Page: https://tour.golang.org/basics/15
Meaning: Create a constant variable foo which will always be an abbreviation for bar
Language: go
Context: Golang

Instruction: for bar{
miam
}
Page: https://tour.golang.org/flowcontrol/3
Effect: while bar holds
do miam
Context: Golang

Instruction: for foo; bar; plop{
miam
}
Page: https://tour.golang.org/flowcontrol/1
Effect: execute foo
while bar holds
do miam
plop
Context: Golang
Assuming: bar non empty

Instruction: for{
miam
}
Page: https://tour.golang.org/flowcontrol/3
Effect: execute miam infinitely often
Context: Golang

Instruction: if foo{
miam
}
Page: https://tour.golang.org/flowcontrol/1
Effect: test whether foo holds. In this case, execute miam
Context: Golang

Instruction: if plop; foo{
miam
}
Page: https://tour.golang.org/flowcontrol/6
Effect: execute plop, test whether foo holds. In this case, execute miam
Context: Golang

Instruction: if plop; foo{
miam
}else{
buz
}
Page: https://tour.golang.org/flowcontrol/6
Effect: execute plop, test whether foo holds. In this case, execute miam, otherwise excute buz
Context: Golang

Instruction: switch plop; foo{
case miam_1:
_ buz_1
...
case miam_n:
_ buz_n
_ default:
coin
}
Page: https://tour.golang.org/flowcontrol/9
Effect: execute plop. Evaluates foo. If its value is equal to one of the miam_i, do buz_i, for i minimal. Otherwise do coin
Context: Golang

Instruction: switch {
case miam_1:
_ buz_1
...
case miam_n:
_ buz_n
_ default:
coin
}
Page: https://tour.golang.org/flowcontrol/11
Effect: for the first i such that miam_i evaluates to true, execute buz_i
Context: Golang

Instruction: defer foo(bar_1,...,bar_n)
Page: https://tour.golang.org/flowcontrol/12
Effect: Evaluates each bar_i.
Execute foo on the result at the end of the evaluation at the end of the current function call and after each defer called after the current instruction
Context: Golang

Question: When multiple defer are called in the same function, in which order are their called
Answer: FILO
Page: https://tour.golang.org/flowcontrol/13

Instruction: nil
Page: https://tour.golang.org/flowcontrol/13
Effect: the zero value of most type
Context: Golang

Instruction: &foo
Page: https://tour.golang.org/flowcontrol/13
Effect: A pointer to the value foo
Context: Golang

Instruction: *foo
Page: https://tour.golang.org/moretypes/1
Effect: The value pointed by the pointer foo
Context: Golang

Instruction: foo.bar
Page: https://tour.golang.org/moretypes/1
Effect: The field bar of a structure foo or of the structure pointed by foo
Context: Golang

Instruction: foo{
bar_1:miam_1,
...
bar_n:miam_n
}
Page: https://tour.golang.org/moretypes/1
Effect: Create a structure of type foo whose field bar_i has value miam_i. Each omitted value has type 0
Context: Golang
Variables: type foo struct{
bar_1 plop_1
_ ...
bar_n plop_n
}
Abbreviation: foo{
miam_1,
...
miam_n
} (all values should be given)
Name: struct literal

Instruction: [n]foo{plop_1, ... , plop_n}
Page: https://tour.golang.org/moretypes/6
Effect: Array of length n whose elements are the plop_i
Context: Golang
Variables: foo a type
Typ: [n]foo

Instruction: []foo{plop_1, ... , plop_n}
Page: https://tour.golang.org/moretypes/6
Effect: ([n]foo{plop_1, ... , plop_n})[:]
Context: Golang
Variables: foo a type
Typ: [n]foo

Instruction: plop[n,m]
Page: https://tour.golang.org/moretypes/6
Effect: A slice containing the elements of the array plop from element n to m-1
Context: Golang
Variables: foo a type
plop an array of type foo

Question: when the higher bound of a slice is omitted
Answer: it is assumed to be the size of the array
Page: https://tour.golang.org/moretypes/10
Context: go

Question: when the lower bound of a slice is omitted
Answer: it is assumed to be 0
Page: https://tour.golang.org/moretypes/10
Context: go

Name: The length of s
Definition: The number of elements contained in s
Page: https://tour.golang.org/moretypes/11
Variables: s a slice
Context: go

Name: The capacity of s
Definition: The number of elements in the underlying array of s
Page: https://tour.golang.org/moretypes/11
Variables: s a slice
Context: go

Name: The underlying array of s
Definition: The array used to create s
Page: https://tour.golang.org/moretypes/11
Variables: s a slice
Context: go

Instruction: len(s)
Page: https://tour.golang.org/moretypes/11
Context: Golang
Returns: The length of s
Variables: s a slice

Instruction: cap(s)
Page: https://tour.golang.org/moretypes/11
Context: Golang
Returns: The capacity of s
Variables: s a slice

Instruction: make([]foo,n)
Page: https://tour.golang.org/moretypes/13
Context: Golang
Returns: A new slice of length and capacity n, initialized at 0, with type foo
Variables: foo a type

Instruction: make([]foo,n,m)
Page: https://tour.golang.org/moretypes/13
Context: Golang
Returns: A new slice of length n and capacity m, initialized at 0, with type foo
Variables: foo a type

Instruction: append(foo_1,...,foo_n)
Page: https://tour.golang.org/moretypes/13
Effect: Append foo_2 to foo_n at the end of the slice foo_1. If foo_1's underlying array is not great enought, create a new array, and copy the foo_i's in it.
Context: Golang

Instruction: for foo,bar:= range miam {
plop
}
Page: https://tour.golang.org/moretypes/16
Effect: For each element bar of miam in position foo, execute plop
Context: Golang

Instruction: for foo:= range miam {
plop
}
Page: https://tour.golang.org/moretypes/16
Effect: For foo from 0 to the length of miam minus 1, execute plop
Context: Golang

Instruction: make(map[foo]bar)
Page: https://tour.golang.org/moretypes/19
Effect: Create an empty map from foo to bar
Context: Golang

Instruction: map[foo]bar{
miam_1:plop_1
...
miam_n:plop_n
}
Page: https://tour.golang.org/moretypes/19
Effect: A map from foo to bar sending miam_i to plop_i
Context: Golang

Instruction: m[plop]
Page: https://tour.golang.org/moretypes/19
Context: Golang
Returns: If a single value is read:
The entry plop of map m
If two values are read:
the entry bar in m, and true, if bar belongs to m.
Otherwise (0,false)
Variables: m a map

Instruction: foo=bar
Page: https://tour.golang.org/moretypes/22
Effect: Assign the value of bar to the variable foo
Context: Golang

Instruction: Adding (foo bar) before the name of a function plop
Page: https://tour.golang.org/methods/1
Effect: State that plop is a method which is applied to elements of type bar named, its variable is called foo in the method body
Context: Golang
Variables: bar a type
Name: receiver argument

Instruction: Adding a * before a type name of a parameter in a function definition
Page: https://tour.golang.org/methods/4
Effect: state that the variable is not copied, but passed by pointer. Thus any modification to the variable affect the variable in the callers
Context: Golang
Name: Pointer recever

Question: Why should you prefer pointer receiver over value receiver
Answer: To modify the receiver
Page: https://tour.golang.org/methods/8
Answer2: to avoid copying the entire structure

Name: Interface type
Definition: a set of method signatures.
Page: https://tour.golang.org/methods/9
Context: Golang

Question: What occurs if you call a method on a variable whose value is nil
Answer: Nothing special
Page: https://tour.golang.org/methods/11
Context: Golang

Question: What occurs if you call a method on "nil"
Answer: error
Page: https://tour.golang.org/methods/11
Context: Golang

Name: An interface value for i
Definition: A variable of type i
Page: https://tour.golang.org/methods/11
Variables: i an interface
Context: Golang

Instruction: x.(T)
Page: https://tour.golang.org/methods/15
Effect: panic if a single value is assigned and it is not of type T
Context: Golang
Returns: If a single value is read:-x as a value of type T
If two values are read
-x as a value of type T if it is indeed a value of type t, and True
-0,False, otherwise
Variables: x a variable whose type is an interface
T a concrete type

Instruction: delete(m,foo)
Effect: remove entry foo from map m
Context: Golang

Instruction: switch foo:=bar.(type){
case T_1:
miam_1
_ ...
case T_n:
miam_n
default:
plop
}
Page: https://tour.golang.org/methods/16
Effect: if bar is of type T_i, execute miam_i, where foo is equal to bar of type type.
Otherwise, execute plop where foo has the same type than bar
Context: Golang

Name: error value
Definition: A value returned by a function, to state whether it works or not
Page: https://tour.golang.org/methods/16
Context: Golang

Instruction: foo.read(slice)
Page: https://tour.golang.org/methods/21
Effect: Populate slice with some bytes from foo.
Context: Golang
Returns: number of bytes read, and an error number

Name: goroutine
Definition: lightweight thread managed by the Go runtime.
Page: https://tour.golang.org/concurrency/1

Instruction: go f(x_1,...,x_m)
Page: https://tour.golang.org/concurrency/1
Effect: evaluates f and each x_i, start a new goroutine executing f(x_1,...,x_m) with the values already evaluated
Context: Golang

Instruction: x<-y
Page: https://tour.golang.org/concurrency/2
Effect: Sends the value y to channel x
Context: Golang
Assuming: some channel receive, otherwise execution is blocked

Instruction: <-y
Page: https://tour.golang.org/concurrency/2
Context: Golang
Returns: A value from channel y. Second value state whether it is closed or not
Assuming: some channel emits, otherwise execution is blocked

Instruction: make (
  chan foo,
  bar
)
Page: https://tour.golang.org/concurrency/3
Effect: Create a channel of type foo with bar bytes of buffer
Context: Golang

Instruction: make (chan foo)
Page: https://tour.golang.org/concurrency/3
Effect: Create a channel of type foo without buffer
Context: Golang

Instruction: close(c)
Page: https://tour.golang.org/concurrency/3
Effect: close the channel c
Context: Golang

Instruction: select{
case foo_1 <- miam_1:
plop_1
...
case foo_n <- miam_n:
plop_n
}
Page: https://tour.golang.org/concurrency/5
Effect: Wait until one of the channel miam_i can be read, assign its vule to foo_i and execute plop_i
Context: Golang

Instruction: default:
Page: https://tour.golang.org/concurrency/5
Effect: Executed if no channel can be read
Context: select in golang

Instruction: Println(foo)
Effect: Print foo followed by a newline
Context: golang
Where to use it: fmt

Typ: interface{}
Meaning: the interface with 0 method
Page: https://tour.golang.org/methods/14
Language: go
Context: Golang
Index: empty interface

Typ: dynamically-sized, flexible view into the elements of an array of type foo
Page: https://tour.golang.org/moretypes/6
Language: go
Context: Golang
Variables: foo a type
Index: slice