TP2957
Go Language Essentials Training
Go is an open source project developed by a team at Google and many contributors from the open source community. It combines the ease of programming of an interpreted, dynamically typed language with the efficiency and safety of a statically typed, compiled language.
Course Details
Duration
4 days
Prerequisites
- Students attending a class should have at least 6 months experience programming in a language such as Java, C / C++, C#.
- Experience programming in a scripting language such as JavaScript or Python is also sufficient.
- No prior experience with Go is assumed or required.
Skills Gained
- Learn the basic structural elements of a Go program
- Learn to use the basic types, aggregate types, reference types, and interfaces
- Learn error-handling strategies
- Learn to compose types and implement encapsulation
- Learn how to create a method (receiver function) on a struct
- Learn how and when to use pointers
- Learn how to use the interface type to enforce a contract
- Learn how and when to use anonymous functions
- Learn how to send and receive data using channels
- Learn concurrency and synchronization techniques
Course Outline
- Setting Up Go
- Installing Go Tools
- go run and go build
- Formatting code
- Linting and vetting
- Go packages
- Makefiles
- Primitive Data Types
- The Zero Value
- Literals
- Booleans
- Numeric Types
- Strings/Runes
- Type Conversion
- var vs :=
- Constants
- Types and untyped constants
- Composite Data Types
- Arrays and Slices
- len, append, capacity, make, copy
- Slicing Slices
- Converting Arrays to Slices
- Maps and Sets
- Structs
- Anonymous Structs
- Conditions
- if
- Complete for Statement
- Condition-only for
- Infinite for
- break and continue
- for-range
- switch
- Functions
- Declaring and Calling Functions
- Named and Optional Parameters
- Variadic Input Parameters and Slices
- Multiple Return Values
- Anonymous Functions
- Closures
- Passing Functions as Parameters
- Returning Functions from Functions
- Defer
- Call by Value
- Pointers
- Pointer Overview
- Pointers and Mutable Parameters
- Pointer Performance
- Methods and interfaces
- Methods
- Functions Versus Methods
- iota Is for Enumerations
- Embedding
- Embedding vs Inheritance
- Interfaces
- Embedding and Interfaces
- Interfaces and nil
- Type Assertions and Type Switches
- Interfaces and Dependency Injection
- Is Go Object-Oriented?
- Errors
- Handling Errors
- Strings for Simple Errors
- defer
- panic and recover
- The Standard Library
- Input/Output
- time
- encoding/json
- Unmarshaling and Marshaling
- JSON, Readers, and Writers
- Encoding and Decoding JSON Streams
- Custom JSON Parsing
- net/http
- The Client
- The Server
- Goroutines and Concurrency
- When You Need Concurrency
- Goroutines
- Channels
- Reading, Writing, and Buffering
- select
- Using a Cancel Function to Terminate a Goroutine
- Mutex
- Mutex vs Channels