Duration
3 days
Overview
Go is a statically typed, compiled and an open source programming language created by Google. Go is syntactically similar to C, but with the added benefits of memory safety, garbage collection, structural typing and CSP-style concurrency. Go's syntax keeps code concise and readable. Go is one of the fastest growing languages in terms of popularity.
Recent years hardware manufacturers are adding more cores to the processors to increase the performance. But, most of the modern programming languages are from the ’90s single threaded environment. Most of those programming languages supports multi-threading. But the real problem comes with concurrent execution, threading-locking, race conditions and deadlocks. Go language was released when multi-core processors were already available. Go is built with keeping concurrency in mind. Go has goroutines instead of threads.
Goroutines have growable segmented stacks. They use more memory only when needed. Goroutines have a faster start up time comparing with traditional threads. Goroutines come with built-in primitives to communicate safely between themselves (channels). Goroutines and OS threads do not have 1:1 mapping. A single goroutine can run on multiple threads. Goroutines are multiplexed into small number of OS threads.
This course is designed to get you up and running as fast as possible with Go. We'll quickly cover the basics, then dive into some of the more advanced features of the language such as Go's concurrency model and interface type systems. Go is like any other language - you have to write code to learn it! This course will give you ample opportunities to strike out on your own and start working on your own programs.
Learning Outcome
- Understand the basic syntax and control structures of the language
- Apply Go's concurrency model to build massively parallel systems
- Grasp the purpose of types, which is especially important if you're coming from a dynamically typed language like JavaScript, Python or Ruby
- Organize code through the use of packages
- Use the Go runtime to build and compile projects
- Get insight into critical design decisions in the language
- Gain a sense of when to use basic language features
Prerequisites
Before attending this course, students should have general programming experience.
Course Topics
Day 1
- Getting Started
- Go Runtime and Compilations
- Keywords and Identifiers
- Constants and Variables
- Operators and Expressions
- Local Assignments
- Numeric
- Characters
- Boolean
- Pointers and Addresses
- Strings
- Constructs
- if-else and switch
- for Statements
- Counter-controlled Iterations
- Condition-controlled Iterations
- Range Loops
- Using break and continue
- Functions
- Parameters and Return Values
- Call by Value and Reference
- Named Return Variables
- Blank Identifiers
- Variable Argument Parameters
- Using defer statements
- Recursive Functions
- Functions as Parameters
- Closures
Day 2
- Organizing Data with Structs
- Structs in Go
- Defining Structs
- Declaring Structs
- Updating Struct Values
- Embedding Structs
- Structs with Receiver Functions
- Pass by Value
- Structs with Pointers
- Pointer Operations
- Pointer Shortcut
- Working with Data
- Array Literals
- Multidimensional Arrays
- Array Parameters
- Slices and Slice Parameters
- Multidimensional Slices
- Reslicing
- Maps and Map Parameters
- Map Slices
- Structures and Structure Parameters
- Structure Tags and Fields
- Embedded Structures
- Recursive Structures
- Methods and Interfaces
- Method Declarations
- Functions vs. Methods
- Pointer and Value Receivers
- Method Values and Expressions
- Interface Types and Values
- Type Assertions and Type Switches
- Method Sets with Interfaces
- Embedded Interfaces
- Empty Interfaces
- Working with Interfaces
Day 3
- Goroutines and Channels
- Concurrency vs. Parallelism
- Goroutine Functions and Lambdas
- Wait Groups
- Channels
- Sending and Receiving
- Unbuffered and Buffered Channels
- Directional Channels
- Multiplexing with select
- Timers and Tickers
- Packages and Testing
- Packages and Workspaces
- Exporting Package Names
- Import Paths and Named Imports
- Package Initializations
- Blank Imports
- Unit Testing with Test Functions
- Table Tests and Random Tests
- Benchmarking
- Working with Go
- Files and Directories
- Reading Directories
- Reading Files
- Writing Files
- Copying Files
- Error Strategies
- Panic and Recover
- Package Error Handling
- Regular Expressions
Programme scope, delivery arrangements and suitability are confirmed during enquiry.