package
0.0.0-20240712133535-75229b5999a3
Repository: https://github.com/agarwalconsulting/go-training.git
Documentation: pkg.go.dev

# README

Overview

For

  • normal for <init>; <condition>; <post> {
  • while for <condition> {
  • forever for {
    • can control execution using break & continue

if

  • with statements
  • if <statement>; <condition> {
    • vars declared within statement are available only within if / else if / else block

Switch statements

  • no break
  • statements are optional
  • top-down execution - where execution stops after a case succeeds
  • normal switch <value> { case <match>
  • takes statement switch <statement>; <value> { case <match>
  • conditional switch { case <bool-statement>:
    • if-else-if

Ranges

  • for along with range
    • range returns index & element
    • for index, element := range "abc" {
    • for <index>, <value> := range <var> {
  • For maps:
    • for <key>, <value> := range <map-type> {