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

# README

Overview

Arrays

  • var <name> [<length>]int
  • len & cap from builtin
  • zero values?

Slices

  • var <name> []int
  • References to underlying array
  • append
    • Eg. append(s, <element1>, <element2>, ...)
    • You have to assign it back to s or whatever is your slice variable name
    • Can have a different behavior depending on capacity
  • make([]<type>, len, cap)
  • make([]<type>, lenAndCap)
  • zero value?

Intro to structs

  • Store related fields of different types
  • struct keyword
    • Usage along with type keyword
    • Anonymous structs
  • Struct Literal syntax

Maps

  • map keyword
    • map[<keyType>]<valType>
  • make(map[string]Person)
  • len only
  • delete
    • Eg. delete(m, <key>)
  • lookup returns 2 values - val, ok
  • zero value?
  • They need to be initialized before usage either with make or map literal syntax: map[string]Person{}

Custom

  • generics are coming in Go 2!
  • Till then rely on interface{} or implement a DS for specific types

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Functions

No description provided by the author

# Structs

No description provided by the author

# Type aliases

No description provided by the author