Step 3 / Select topic Go Easy

What this bank covers

  • Unsigned integer wraparound in Go
  • Integer vs floating-point division in Go
  • Unsigned integer arithmetic wraps around in Go
  • Untyped constant division in Go
  • Integer division and remainder with negative operands in Go
  • Signed integer overflow wraps in Go
  • float64 is binary, not decimal
  • fmt prints maps in sorted key order
  • Ranging over an integer
  • Interface equality compares the dynamic type too
  • math.Sqrt and math.Pow
  • Floating-point division by zero
  • HasPrefix and HasSuffix test the ends of a string
  • strings.Fields collapses runs of whitespace
  • strings.TrimSpace strips leading and trailing whitespace
  • In-order traversal of a binary search tree
  • container/heap builds a min-heap from Less
  • Multiple return values
  • Functions as values
  • select with a default case
  • Atomic counter plus WaitGroup gives a deterministic total
  • Go's &^ bit-clear operator
  • rune is an alias for int32
  • Operator precedence for * and +
  • strings.Index and the missing-substring result
  • strings.Split keeps empty fields
  • strings.Replace with a count limit
  • strings.Index returns a byte offset
  • strings.Count and the empty substring
  • strings.Repeat and strings.Join
  • ranging over a map visits every key once
  • range over a channel drains it until it is closed
  • breaking out of a range-over-function iterator
  • the range expression is evaluated once
  • ranging over an array iterates a copy
  • Range over a function iterator
  • maps.Keys returns an iterator
  • Slice capacity growth on append
  • Missing map keys give the zero value
  • Arrays are copied on assignment
  • Traversing a singly linked list
  • A slice used as a FIFO queue
  • Comparable structs as map keys
  • Sorting an int slice in place
  • Block scope and shadowing
  • Named results and deferred functions
  • Package-level scope
  • Arguments are passed by value
  • recover stops a panic inside a deferred call
  • Go switch cases do not fall through
  • errors.Is unwraps %w chains
  • break with a label exits the labeled loop
  • defer runs on every return path
  • Deferred calls can change a named result
  • On error, Go functions return the zero value
  • len and cap on a buffered channel
  • Receiving from a closed channel
  • sync.Once runs a function one time
  • Mutex plus WaitGroup give a deterministic total
  • select prefers a ready case over default
  • context cancellation and ctx.Err
  • sync.Once with concurrent goroutines
  • Memoization returns the same value, faster
  • Preallocating capacity avoids regrowth
  • Binary search on a sorted slice
  • Dynamic programming beats greedy for coin change
  • Kadane's algorithm in one pass
  • Sieve of Eratosthenes under 50
  • 0/1 knapsack with a single DP row
  • Exponentiation by squaring
  • strings.Builder is an optimization, not a behaviour change
  • Early exit does not change the first-match result
  • string(rune(n)) versus strconv.Itoa(n)
  • Struct copies: arrays by value, slices by reference
  • Deferred arguments evaluate early, closures read late
  • copy returns the number of elements copied
  • strings.Count counts non-overlapping occurrences
  • Collecting a range-over-func iterator
  • time.Duration prints as formatted text
  • Integer division and remainder with negative operands
  • Unsigned integer overflow wraps around
  • Sign of the % operator
  • math.Round and halfway values
  • Left shift as a power of two
  • Floating-point equality
  • math.Mod keeps the dividend's sign
  • Square root then modulo in Go
  • Ranging over a string
  • Slice-backed stack pops in LIFO order
  • Parameters are copies
  • Closures capture variables, not copies
  • recover with a named result
  • fallthrough moves to exactly one more case
  • Ranging over a closed channel
  • Typed nil inside an interface
  • Append writing into a shared backing array
  • Rune count versus byte length