Setup your Environment
Grab the Roadmap!
Install Go on OS X
Install Go on Windows
Find your way in the code repository
Get the code for the course
Write Your First Go Program
Write Your First Go Program!
What is GOPATH?
Create folders and files
Write your first program
Compile with "go build"
Learn the difference between Compile-Time and Runtime
Run with "go run"
Prove Yourself: First Go Program
★ FIRST GO PROGRAM EXERCISES ★
⭐️ Packages ⭐️
Let's understand the first program
What is a package?
Learn the differences between Executable and Library Packages
Prove Yourself: Packages
Scopes: What is the importance of names?
What is a package scope?
The same names in the same package
Importing happens in the file scope
Renaming imported packages
Prove Yourself: Scopes
⭐️ Statements and Expressions ⭐️
What is a statement?
What is an expression?
Print the number of CPUs
Prove Yourself: Statements and Expressions
How Go comments work?
What is Go Doc?
★ FUNDAMENTALS EXERCISES ★
⭐️ Write a Library Package! ⭐️
Create your first library package
How Go standard library exports?
Export a function from your package
Prove Yourself: Library Packages
★ LIBRARY PACKAGE EXERCISES ★
Master the Type System of Go
⭐️ Variables ⭐️
Roadmap
Introduction to Variables
Learn the basic data types of Go
Prove Yourself: Basic Data Types
★ DATA TYPES EXERCISES ★
How to declare a variable?
Every Go type has a zero value
What is a blank identifier?
How to declare multiple variables?
Let's declare a couple of variables!
Prove Yourself: Variable Declarations
★ DECLARATION EXERCISES ★
What is type inference?
Why can't you short declare a variable in the package-level?
How to short declare multiple variables?
What is redeclaration?
When to use a short declaration?
Prove Yourself: Short Variable Declaration
★ SHORT DECLARATION EXERCISES ★
How to assign to a single variable?
How to assign to multiple variables?
Mini Example: Path Separator
Prove Yourself: Assignments
★ ASSIGNMENT EXERCISES ★
Let's convert a value!
Learn the importance of type names
Prove Yourself: Type Conversion
★ TYPE CONVERSION EXERCISES ★
⭐️ Get input from terminal ⭐️
Learn the basics of os.Args
Greet people using os.Args
Recap: Variables
Prove Yourself: Command-Line Args
★ OS.ARGS EXERCISES ★
⭐️ Print Formatted Output ⭐️
Println vs Printf
What is an Escape Sequence?
How to print using Printf?
The verbs can be type-safe too!
Recap: Let's summarize
Prove Yourself: Printf
★ PRINTF EXERCISES ★
⭐️ Numbers and Strings ⭐️
Learn the basic arithmetic operators of Go
What is the result of 3/2?
Prove Yourself: Arithmetic Operators
★ Convert Celsius to Fahrenheit
What is the IncDec Statement?
Calculate the area using assignment operations
Convert Feet to Meters
Recap: Numbers
Prove Yourself: Assignment Operations
★ NUMBERS EXERCISES ★
What is a Raw String Literal?
How to combine multiple strings?
How to get the length of a string?
Example: Banger: Yell it back!
Recap: Strings
Prove Yourself: Strings
★ STRINGS EXERCISES ★
⭐️ Go Type System Mechanics ⭐️
Introduction and Roadmap
[For Beginners] Bits and Bytes #1
[For Beginners] Bits and Bytes #2
What is a Predeclared Type?
Overflow: Go beyond?
Prove Yourself: Data Types
Understand the Defined Types
Defined Types: Real-Life Example
Create Your Own Types
Underlying Types
Underlying Types: Example
Aliased Types: Don't use it at home
Recap: Go Type System
Prove Yourself: Defined and Underlying Types
★ TYPES EXERCISES ★
⭐️ Untyped Constants ⭐️
Introduction and Roadmap
Why might you want to use a constant?
Learn the rules of constants
Examples of Typed Constants
How to declare multiple constants?
Recap: Constants
How untyped constants work under the hood?
What is a Default Type?
Example: time.Duration
Refactor: Feet to Meters
Recap: Typeless Constants
What is iota?
Recap: iota
Prove Yourself: Constants
★ CONSTANTS EXERCISES ★
Naming Things: Recommendations
Control Flow and Error Handling
⭐️ If Statement ⭐️
Introduction and Roadmap
[For Beginners] Comparison Operators
Learn the relation between comparison and assignability
Prove Yourself: Comparison Operators
[For Beginners] Logical AND
[For Beginners] Logical OR
[For Beginners] Logical NOT
Recap: Boolean Operators
Prove Yourself: Logical Operators
[For Beginners] If Statement
[For Beginners] Else and Else If
Refactor: Feet to Meters
Prove Yourself: If Statement
Recap: If Statement
★ IF EXERCISES ★
★ Pass Me: Create a Password-Protected Program
Tiny Challenge: Validate a single user
Solution: Validate a single user
Tiny Challenge: Validate multiple users
Solution: Validate multiple users
⭐️ Error Handling ⭐️
Introduction
What is a nil value?
What is an error value?
Error handling example
Challenge: Feet to Meter
Solution: Feet to Meter
Recap: Error Handling
Prove Yourself: Error Handling
What is a Simple Statement?
Scopes of simple statements
Famous Shadowing Gotcha
Prove Yourself: Short If
Recap: Error Handling
★ ERR HANDLING EXERCISES ★
⭐️ Switch Statement ⭐️
Introduction and Roadmap
Learn the Switch Statement Basics
What is a default clause?
Use multiple values in case conditions
Use bool expressions in case conditions
How does the fallthrough statement work?
What is a short switch?
Tiny Challenge: Parts of a Day
Solution: Parts of a Day
If vs Switch: Which one to use?
Recap: Switch Statement
Prove Yourself: Switch Statement
★ SWITCH EXERCISES ★
⭐️ Loops ⭐️
Introduction and Roadmap
There is only one loop statement in Go
How to break from a loop?
How to continue a loop? (+BONUS: Debugging)
Create a multiplication table
★ LOOP EXERCISES #1 ★
How to loop over a slice?
For Range: Learn the easy way!
Recap: Loops
Prove Yourself: Loop
★ LOOP EXERCISES #2 ★
Projects: For Beginners
Randomization in Go
Randomization and Go
Seed the randomizer with time
Write the Game Logic
Prove Yourself: Randomization
★ RANDOMIZATION EXERCISES ★
Mini Project: Word Finder
Build the Word Finder Program
Labeled Break and Continue
Break from a Switch
Yes there is a "goto" statement in Go
Prove Yourself: Labeled Statements
★ LABELED STATEMENT EXERCISES ★
Arrays and Memory Layout
Learn Go's Fixed Arrays
Introduction and Roadmap
What is an array in Go?
Let's create an array
Learn the gotcha when using a for range on arrays
Prove Yourself: Arrays #1
What is a composite literal?
Refactor the Hipster's Love Bookstore to array literals
Tiny Challenge #1: Moodly
Can you compare array values?
Can you assign an array value to another one?
★ ARRAYS EXERCISES #1 ★
How to use multi-dimensional arrays?
Tiny Challenge #2: Moodly
Learn the rarely known feature of Go: The Keyed Elements
Learn the relation between composite and unnamed types
Prove Yourself: Arrays #2
Recap: Arrays
★ ARRAYS EXERCISES #2 ★
Project: Write a Retro Clock
Grab the Slides!
Challenge: Retro Led Clock
Challenge Explanation
Let's print the digits
Let's print the clock
It's time to animate the clock!
★ RETRO CLOCK EXERCISES ★
Slices and Internals
Slices: Master Go's Dynamic Arrays
Introduction and Roadmap
Learn the differences between slices and arrays
Can you compare a slice to another one?
Create a unique number generator
Prove Yourself: Slices vs Arrays
★ SLICE EXERCISES ★
Append: Let's grow a slice!
Prove Yourself: Appending
★ APPEND EXERCISES ★
Slicing: Let's cut that slice!
How to create pagination using slices? (+ Sprintf)
Prove Yourself: Slicing
★ SLICING EXERCISES ★
⭐️ Slice Internals ⭐️
What is a Backing Array?
Prove Yourself: Backing Array
What's a slice header?
What does a slice header look like in the actual Go runtime code?
Prove Yourself: Slice Header
What is the capacity of a slice?
Extend a slice using its capacity
Prove Yourself: Capacity
When does the append function create a new backing array?
Animate: When the backing array of a slice grows?
Prove Yourself: Mechanics of Append
★ SLICE INTERNALS EXERCISES ★
⭐️ Advanced Operations ⭐️
Full Slice Expressions: Limit the capacity of a slice
make(): Preallocate the backing array
copy(): Copy elements between slices
How to use multi-dimensional slices?
Prove Yourself: Advanced Slice Operations
★ ADVANCED SLICE OPS EXERCISES ★
Project: Write a File Finder
Build an Empty File Finder Program
Fetch the Files
Write to a file
Optimize!
★ FILE FINDER EXERCISES ★
Project: Animate a Bouncing Ball
Project: Animate a Bouncing Ball
Challenge
Challenge Document
Step #1: Create and Draw the Board
Step #2: Optimize by adding a Buffer
Step #3: Animate the Ball
★ BOUNCING BALL EXERCISES ★
UTF-8: Encode and Decode
Learn how to encode and decode UTF-8 strings
Introduction and Roadmap
★ Resources ★
Let's learn the basics of bytes, runes and strings
Let's write a character-set program
Let's convert, index, and slice bytes, runes and strings
How can you decode a string?
String Header: Why strings are immutable?
Recap: Strings Revisited
Prove Yourself: Strings, Bytes, and Runes
★ UTF-8 EXERCISES ★
Project: Create a Spam Masker
Project: Let's Build a Spam Masker
Challenge
Challenge Document
Detect the link patterns
Mask the links
★ Text Wrapper Challenge ★
Let's build a Unicode text wrapper
Maps and Internals
Learn Go's Maps and Internals
Create an English to Turkish dictionary
Populate the dictionary
Map Internals: How maps work behind the scenes?
Prove Yourself: Maps
★ MAP EXERCISES ★
Project: Create a Log Parser
Scan for Input using bufio.Scanner
Scan user input using bufio.Scanner
Use maps as sets
Create a Log Parser using maps and bufio.Scanner
Prove Yourself: Input Scanning
★ SCANNER EXERCISES ★
Structs: Encode and Decode JSON
Structs: Organize Data
What is a struct?
Let's create a struct!
When can you compare struct values?
Go OOP: Struct Embedding
Rewrite: Log Parser to Structs
Encode values to JSON
Decode values from JSON
Prove Yourself: Structs
★ STRUCT EXERCISES ★
Functions, Pointers and Addressability
Functions: The Building Blocks
Learn the function basics
Confine variables to a function
Rewrite: Log Parser using functions
Learn the Pass By Value Semantics
Prove Yourself: Functions
★ FUNC EXERCISES ★
Pointers: Indirectly update data
What is a pointer?
Learn the pointer mechanics
Learn how to work with pointers to composite types
Rewrite the Log Parser using Pointers
Pointers or Values? Be Consistent
Prove Yourself: Pointers
★ POINTER EXERCISES ★
Methods: OOP with Go
Methods: Grab the code
Methods: Enhance types with additional behavior
Pointer Receivers: Change the received value
Non-Structs: Attach methods to almost any type
Interfaces: Implicit OOP Way
Interfaces: Grab the code!
Interfaces: Be dynamic!
Type Assertion: Extract the dynamic value!
Empty Interface: Represent any type of value
Type Switch: Detect and extract multiple values
Promoted Methods: Let's make a little bit of refactoring
Interfaces: Marshaler, Sorter, and so on
Famous Interfaces: Grab the code!
Don't interface everything!
Stringer: Grant a type the ability to represent itself as a string
Sorter: Let a type know how to sort itself
Marshalers: Customize JSON encoding and decoding of a type
BONUS SECTION: THANK YOU!
Bonus Lecture