5. WHAT IS GO?
➤ Statically-typed (with some dynamic characteristics), concurrent,
quickly compiled & garbage-collected language that generates docs
automatically!
➤ Developed by Google in 2007 by Rob Pike, Ken Thompson and Robert
Greisemer
➤ Who is using it? https://github.com/golang/go/wiki/GoUsers
6.
7.
8. PHILOSOPHY
➤ “Go is intended to be fast: it should take at most a few seconds
to build a large executable on a single computer.”
➤ Avoid overhead of C-style languages of include files and
libraries
➤ Make types feel more lightweight in Go than in OOP language
like Java
➤ Combine features of dynamically typed languages
9. WHAT’S GOOD ABOUT GO?
➤ Fast build times, single binary deployment, built in formatting, great tooling, built in
test framework, multi-arch build, low-level interface, race detector, visual profilers,
and a nice concurrency model
➤ Imperative programming style & procedural paradigm
➤ Concurrency (dealing with lot of things at once) & Parallelism (doing a lot of things
at once)
➤ Remote package management (go get github.com/<username>/<repo>)
➤ Great for backend services, process heavy stuff, non blocking IO, service calls
➤ Comes with a cost: no exceptions & assertions, enter pointers, structs and variable
declaration
11. 101: INTRO TO GO
Source is UTF-8
No semicolons or rules related to tabs or
spacing like Python
Parenthesis are not required except for
argument lists
Includes all familiar types including support for
int8, uint32, float64, etc.
Strings are immutable
Only control statements are if, for, switch, and
defer
All memory in Go is initialized (un-initialized
variables are of "zero value")
Runs on the i386, amd64, and ARM architectures
with the "gc" compilers
Declarations are reversed with type at end,
supports multiple assignment, shorthand
declarations with functions only
More useful Go features: slices, defer, iota, and
the blank identifier “_"
Garbage collection is performed by mark-and-
sweep
21. CONCURRENCY
➤ goroutines (execution)
➤ Do not communicate by sharing
memory but instead share
memory by communicating
➤ Functions executing concurrently
with others in the same address
space
➤ Channels (sync & message)
➤ Asynchronously (buffered) or
synchronously (unbuffered) send
data between two goroutines
23. WHAT’S BAD ABOUT GO?
➤ Not quite OOP means no concept of inheritance and polymorphism
➤ No support for overloading of methods and operators
➤ No pointer arithmetic and implicit type conversions
➤ No support for Generics/Templates
➤ Instead relies on built in maps, slices and explicit unboxing to provide similar
functionality
➤ Type inheritance is not supported
➤ Types automatically satisfy any interface that specifies a subset of its methods.