Go Language basics
numeric 0 value
0
declaring with an initial value
0 values
defer statement
a function doesn't execute until the function it is contained under returns
strongly typed language
a language in which all variables must be declared before they can be used.
runtime reflection means
ability to work with code not yet written
3 advantages to deferring file.Close()
call is near file.Open(); if surrounding function has multiple return statements, Close() will occur before them;
Go follows __case
camel
Go syntax is
clean, expressive, concise, and efficient
variables in Go may
contain numbers; contain underscore
a __ is passed to the function
copy of the variable
panic()
creates a runtime error
:=
declare & initialize; type inference
when to use defer
defer file.Close()
*yPtr = 0
dereferencing
type switch
each case contains a type that's compared to the switch
expression switch
each case contains an expression that's compared to the switch
boolean 0 value
false
format verb
from fmt package
Go Programming Language is
general purpose; open source
recover()
halts panic and returns value passed to panic
factored import
import ( ... )
deferred call stack executed
last-in-first-out
call to a deferred function occurs
later
Go allows for
modular constructions
Go is ideal for
multicore and networked machines
stacking functions
nested function calls add most recently called to the top of the call stack; returned first, and popped off the call stack
RPC package
net/rpc/jsonrpc
Go compiles
rapidly
new(int)
returns a pointer to a memory address of size 'int'
deferred function arguments are evaluated
right away
a runtime panic occurs, a deferred function will
run anyways
Go performs
runtime reflection
variables in Go must
start with letter
passing a pointer to a function enables
that function to modify the original variable's value
in Go { must be on
the same line as the function declaration
fun(&y)
variable address
string 0 value
""