Introduction Flashcards
Strings are ___ indexed in Go
0
Integer types in Go
uint8, uint16, uint32, uint64, int8, int16, int32, and int64
Three logical operators in Go
&& - and, || - or, ! - not
Rules for naming variables in Go
- Start with a latter
2. Can contain letters, numbers and _
Keyword for declaring a variable in Go
var
Keyword for declaring a constant in Go
const
Two ways of declaring variables in Go
- Using the var keyword inline
2. Using the var keyword with a block [ var (…) ]
What scoping rules does Go use?
Lexcial scoping
What options are available for controlling flow in Golang?
for, if and switch
How should you write a while loop in Go?
for {…} or for true {…}
What is the difference between “” and `` in Go?
Strings created from “” can contain only escape sequences. Strings created from `` can contain new lines and other literal.s
How are arrays initialized in go
var []
The ____ function can be used to find the length of arrays and strings in Go
len
To convert between types in Go, you ______
Use the type names like a function
We use the keyword _____ followed by the name of the variable we want to loop over
range
A _______ is used to tell the compiler that we don’t need this variable
single underscore (_)
Short syntax for creating arrays in Go
[]{…items…}
The length of the slice type in Go is constant. True or false?
False
What are the ways in which you can create a slice in Go?
- Using the make function
2. Indexing arrays (arr[low: high])
What are the arguments to the copy function?
dst (destination) and src (source)
How should maps be created in Go?
var := make(map[])
The _____ function can be used to delete items from a map
delete
What is a variadic parameter?
A parameter which can be used to accept multiple arguments of a single type
How to define
func (args …) {}
The ____ keyword can be used to move a function call to the end
defer
Deferred function calls happen before the function returns. True of false?
True