Learn Go The Complete Bootcamp Golang

Master and Deeply Understand Google's Go from Scratch with Illustrated In-Depth Tutorials & 1000+ Hands-On Exercises.

Last updated 2022-01-10 | 4.5

- Learn from a Go Contributor
- Learn Go Tips & Tricks that you can't find easily anywhere else
- Go from a total Go beginner to a confident Go programmer

What you'll learn

Learn from a Go Contributor
Learn Go Tips & Tricks that you can't find easily anywhere else
Go from a total Go beginner to a confident Go programmer
Practice Go with 1000+ Exercises (with included solutions)
Understand Go In-Depth with Animated Illustrations (Pass Interviews)
Learn the Go internals and common Go idioms and best-practices
Create a Log File Parser that parses log files
Create a Spam Masker that masks spammy words within a block of text
Create a command-line Retro Led Clock that shows time
Create Console Animations
Dictionary Programs
and more

* Requirements

* Access to a computer with an internet connection.

Description

Go is a programming language created by Google, and this course is the most intuitive, in-depth, and highest-quality Go course on Udemy, with an insane level of attention to detail. You'll understand both the why and how. We've included thousands of animations, exercises, quizzes, examples, challenges, projects, and so on. By the end of the course, you'll become a confident Go programmer from scratch.

Why should you take this course now?

  • Watch ultra-detailed, entertaining, intuitive, and easy to understand illustrations and animations.

  • Solve 1000+ hands-on exercises (solutions are also included).

  • Create projects including a log parser, file scanner, spam masker, and more.

  • Learn Go programming tips and tricks that you can't find easily anywhere else.

  • Learn the Go internals and common Go idioms and best-practices.

Why should you learn Go (aka Golang and Go lang)?

  • Go is one of the most desired, easy to learn, and the highest paying programming languages. There are 1+ million Go programmers around the world, and the number is increasing each day exponentially. It's been used by Google, Facebook, Twitter, Uber, Docker, Kubernetes, Heroku, and many others.

  • Go is Efficient like C, C++, and Java, and Easy to use like Python and Javascript. It's Open-Source, Simple, Powerful, Efficient, Cross-Platform (OS X, Windows, Linux, ...), Compiled, Garbage-Collected, and Concurrent.

  • Go is best for Command-line Tools, Web APIs, Distributed Network Applications like Microservices, Database Engines, Big-Data Processing Pipelines, and so on.

What are you going to learn from this course (briefly)?

  • Go OOP: Interfaces and Methods

    • Internals of Methods and Interfaces

    • Functions and Pointers: Program design, pass by value, and addressability.

    • Implicit interface satisfaction

    • Type assertion and Type Switch

    • Empty interface: []interface{} vs interface{}

    • Value, Pointer, and Nil Receivers

    • Promoted Methods

  • Famous Interfaces

    • Tips about when to use interfaces

    • fmt.Stringer, sort.Sort, json.Marshaler, json.Unmarshaler, and so on.

  • Composite Types: Arrays, Slices, Maps, and Structs

    • Internals of Slices and Maps

    • Backing array, slice header, capacity, and map header

    • JSON encoding and decoding, field tags, embedding

    • Make, copy, full Slice expressions and append mechanics

    • UTF-8 encoding and decoding

  • Go Type System Mechanics

    • Type inference, underlying, predeclared, and unnamed types.

    • Untyped constants and iota.

    • Blank Identifier, short declaration, redeclaration, scopes, naming conventions

  • I/O

    • Process Command-Line Arguments, printf, working with files, bufio.Scanner, ...

  • How to create your own Go packages

    • How to run multiple Go files, and how to use third-party packages

  • Go tools

    • Debugging Go code, go doc, and others.

  • ...and more.

Who this course is for:

  • Take this course as the best companion to fully understand the official Go Spec and book.
  • Beginners who have never programmed before.
  • Programmers switching languages to Go.
  • Go programmers who want to level up their skills!
  • Go programmers who want to learn the internals of slices, maps, interfaces, and so on.

Course content

17 sections • 214 lectures

Installation and Resources Preview 00:26

Introduction to Variables Preview 08:05

  • How to declare a variable

  • Parts of a variable declaration syntax

  • Naming rules

Example: Path Separator Preview 05:31

  • Path package

  • Path.Split function

  • Function declaration syntax

  • Using blank-identifier with multiple result returning expressions

When to use a short declaration? Preview 06:11

  • Recommendations about when to use a short declaration vs a variable declaration.

  • Code examples

Let's convert a value! Preview 07:09

  • How to change the type of a value to another type?

  • Type conversion expression syntax

  • Importance of the order of type conversions

  • Rules

⭐️ Get input from terminal ⭐️ Preview 04:54

  • Getting arguments from the command-line

  • os Package and os.Args

  • Introduction to Slices

  • Index expressions

Learn the basics of os.Args Preview 04:06

Naming Things: Recommendations Preview 08:25

"There only two hard things in computer science: Cache invalidation and Naming things."

  • The subject of this lecture is about naming things of course.

  • We're going to look at a lot of examples for properly naming your identifiers.

NOTE: This lecture is about using names in Go in general.

★ EXERCISES ★ Preview 00:18

What is a Raw String Literal? Preview 06:35

  • What is a Raw String Literal?

  • String Literals vs Raw String Literals

  • Code Along Examples

How to get the length of a utf-8 string? Preview 04:36

  • How to get the length of a string?

  • Interesting details about the len function

  • Calculating the length of unicode characters

  • Very gentle introduction to Runes and Codepoints

Example: Banger: Yell it back! Preview 04:41

  • Introduction and usage of strings package

  • Getting input from the command line

  • And manipulating it using the strings package

  • String concatenation and using functions

★ STRINGS EXERCISES ★ Preview 00:02

Constants and iota Preview 09:53

  • What's iota? Why you want to use it? What it does?

  • Using blank-identifier in constant declarations

  • Creating a timezone table using iota and constants

★ IOTA EXERCISES ★ Preview 00:01

⭐️ Print Formatted Output ⭐️ Preview 00:05

Println vs Printf Preview 07:44

  • How to print formatted output?

  • How Printf works

  • The mechanics of the Printf function

What is an Escape Sequence? Preview 04:08

  • What is an escape sequence?

  • What is an escape character?

How to print using Printf? Preview 07:47

  • How to print the type of any value?

  • Examples for common verbs

  • Swiss Army Knife Verb

  • Argument Indexing

The verbs can be type-safe too! Preview 05:09

  • Type-Safety and Printf

  • Changing the printed precision

★ PRINTF EXERCISES ★ Preview 00:06

⭐️ If Statement ⭐️ Preview 00:16

If Statement Preview 05:12

Else and Else If Preview 03:51

★ IF STATEMENT EXERCISES ★ Preview 00:04

Tiny Challenge: Validate a single user Preview 02:34

Solution: Validate a single user Preview 07:50

Tiny Challenge: Validate multiple users Preview 01:40

Solution: Validate multiple users Preview 06:46

⭐️ Error Handling ⭐️ Preview 00:08

What is a nil value? Preview 04:27

What is an error value? Preview 06:30

Error handling example Preview 03:43

Challenge: Feet to Meter Preview 00:53

Solution: Feet to Meter Preview 03:12

What is a Simple Statement? Preview 04:15

Scopes of simple statements Preview 06:13

Famous Shadowing Gotcha Preview 05:12

★ ERR HANDLING EXERCISES ★ Preview 00:05

⭐️ Switch Statement ⭐️ Preview 00:08

Learn the Switch Statement Basics Preview 09:25

  • What's an expression switch?

  • What's a switch condition? How it works?

  • What's a case clause?

  • What's the difference between a switch statement and an if statement?

What is a default clause? Preview 03:26

Use multiple values in case conditions Preview 02:25

Use bool expressions in case conditions Preview 03:51

How does the fallthrough statement work? Preview 06:52

What is a short switch? Preview 03:00

Tiny Challenge: Parts of a Day Preview 04:03

Solution: Parts of a Day Preview 03:36

If vs Switch: Which one to use? Preview 05:58

★ SWITCH EXERCISES ★ Preview 00:02

⭐️ Loops ⭐️ Preview 00:07

There is only one loop statement in Go Preview 06:02

How to break from a loop? Preview 05:23

How to continue a loop? (+BONUS: Debugging) Preview 05:25

Create a multiplication table Preview 05:40

How to loop over a slice? Preview 05:22

For Range: Learn the easy way! Preview 07:25

★ LOOP EXERCISES #1 ★ Preview 00:03

Randomization in Go Preview 00:07

Randomization and Go Preview 07:08

Seed the randomizer with time Preview 04:11

Write the Game Logic Preview 07:30

Prove Yourself: Randomization

★ RANDOMIZATION EXERCISES ★ Preview 00:02

Mini Project: Word Finder Preview 00:05

Build the Word Finder Program Preview 07:35

Labeled Break and Continue Preview 09:08

Break from a Switch using Labels Preview 04:09

Yes there is a "goto" statement in Go Preview 05:18

Prove Yourself: Labeled Statements

★ LABELED STATEMENT EXERCISES ★ Preview 00:02

Learn Go's Fixed Arrays Preview 00:24

Introduction and Roadmap Preview 06:09

  • Until now, you were using singular values. Now it's time to learn about more advanced data types.

  • In this part you're going to learn almost everything about the composite types.

  • We're starting with the arrays, that is one of the composite types.

What is an array in Go? Preview 09:19

You're going to learn:

  • What's an array

  • How Go represents an array in computer memory

  • How to use arrays

Let's create an array Preview 04:57

You're going to learn:

  • What's an array

  • How Go represents an array in computer memory

  • How to use arrays

Learn the gotcha when using a for range on arrays Preview 07:33

You're going to learn:

  • An example usecase for arrays (cont.)

  • Using parallel arrays for representing data

  • Gotchas when using the for range clause with arrays

Prove Yourself: Arrays #1

What is a composite literal? Preview 05:06

You're going to learn:

  • Composite literal declaration syntax

  • How an array literal simplifies creating new arrays

  • Useful feature of trailing commas in composite literals

  • Ellipsis syntax when declaring arrays

  • Zero values of array elements

Refactor the Hipster's Love Bookstore to array literals Preview 06:19

You're going to refactor the Hipster's Love Bookstore example to array literals.

Tiny Challenge #1: Moodly Preview 02:27

  • Use arrays to print random moods from an array.

  • Learn how to use the random number generator with arrays.

Can you compare array values? Preview 07:48

Can you assign an array value to another one? Preview 06:47

You're going to learn:

  • How Go assign an array to another array?

  • Importance of comparison when assigning arrays

  • Code along example for the copying behavior and array assignments

★ ARRAYS EXERCISES #1 ★ Preview 00:04

How to use multi-dimensional arrays? Preview 08:45

You're going to learn:

  • How to use multi-dimensional arrays (array of arrays)?

  • The rules of multi-dimensional array declaration and usage

  • Simplified array literal element declaration syntax

  • Refactor a program that uses single-dimensional arrays to multi-dimensional arrays

Tiny Challenge #2: Moodly Preview 04:14

  • Refactor the previous Moodly challenge to multi-dimensional arrays

Learn the rarely known feature of Go: The Keyed Elements Preview 08:46

You're going to learn:

  • Rarely known feature of Go arrays: Keyed elements

  • Use keyed elements to describe the index positions

  • Hidden details of the keyed element declaration in array literals

  • Cryptocurrency exchange ratios program using the keyed elements

Learn the relation between composite and unnamed types Preview 10:43

You're going to learn:

  • The difference between named and unnamed types

  • The relation of composite types and unnamed types

  • Comparison and assignment rules of named and unnamed composite types

  • Code along usage example

Prove Yourself: Arrays #2

Recap: Arrays Preview 04:09

★ ARRAYS EXERCISES #2 ★ Preview 00:03

Grab the Slides! Preview 00:02

Challenge: Retro Led Clock Preview 06:41

Challenge Explanation Preview 00:33

You can find the links about the detailed explanations for the challenge steps and solutions.

Let's print the digits Preview 07:26

Let's print the clock Preview 06:49

It's time to animate the clock! Preview 08:16

★ RETRO CLOCK EXERCISES ★ Preview 00:27

Slices: Master Go's Dynamic Arrays Preview 00:24

Introduction and Roadmap Preview 03:09

Let's see what you're going to learn in this section.

Learn the differences between slices and arrays Preview 06:00

You're going to learn the differences between slices and arrays.

Can you compare a slice to another one? Preview 10:15

You're going to learn:

  • The differences between slices and arrays

  • Comparing and Assigning Slices

  • Nil Slice vs Empty Slice

  • Using the Length of slices when comparing

  • Arrays, slices and the Go Standard Library

Create a unique number generator Preview 07:14

You're going to learn:

  • The differences between slices and arrays

  • A use case for a slice

  • Refactoring the program from arrays to slices

  • A very gentle introduction to the append function and the slice expressions

  • Arrays, slices and the Go Standard Library: sort.Ints function

Prove Yourself: Slices vs Arrays

★ SLICE EXERCISES ★ Preview 00:07

Append: Let's grow a slice! Preview 07:25

You're going to learn:

  • The usage of the built-in append function

  • The return value of the append

  • Appending multiple elements and a slice

  • Simple TODO list example using appends

Prove Yourself: Appending

★ APPEND EXERCISES ★ Preview 00:08

Slicing: Let's cut that slice! Preview 09:33

You're going to learn:

  • What is a sliceable value? 

  • How the slice expressions (slicing) work?

  • What is reslicing?

How to create pagination using slices? (+ Sprintf) Preview 04:47

You're going to learn:

  • How to create pagination using slice expressions?

  • How the sprintf function works?

Prove Yourself: Slicing

★ SLICING EXERCISES ★ Preview 00:03

⭐️ Slice Internals ⭐️ Preview 00:10

What is a Backing Array? Preview 10:45

You're going to learn:

  • How do slices work under the hood?

  • What's really a slice?

  • What's a backing array?

  • How Go represents the backing array in computer memory?

Prove Yourself: Backing Array

What's a slice header? Preview 05:28

You'll understand what a slice value actually is:

  • How a slice value is stored?

  • What's a slice header? What does it do?

  • What's the pointer field of the slice header?

  • Does nil slice have also a slice header?

What does a slice header look like in the actual Go runtime code? Preview 07:28

  • What does a slice header (or slice value) looks like in the actual Go runtime code?

  • When you pass a slice to a function, what gets passed actually?

  • How about an array? Do they work like the same when they're copied?

Prove Yourself: Slice Header

What is the capacity of a slice? Preview 05:09

You will understand what the capacity of a slice means.

  • Why the capacity of a nil slice is zero?

  • What's the difference between the length and the capacity of a slice?

  • What's the role of the slice header's pointer field? Why is it related to the capacity?

  • How can you extend a slice using its capacity?

  • How to use the cap function?

Extend a slice using its capacity Preview 06:03

  • Understand when to use parallel slice values.

  • What's a dummy backing array? What is their role?

  • Extend an empty slice using its capacity inside a loop.

Prove Yourself: Capacity

When does the append function create a new backing array? Preview 07:16

You're going to learn:

  • The relationship between the backing array and the append function.

  • When does the append function create a new backing array?

Animate: When the backing array of a slice grows? Preview 06:17

The full demonstration of the append function when allocating backing arrays.

Prove Yourself: Mechanics of Append

★ SLICE INTERNALS EXERCISES ★ Preview 00:25

⭐️ Advanced Operations ⭐️ Preview 00:09

Full Slice Expressions: Limit the capacity of a slice Preview 06:03

Understand when to and how can you use the full slice expression to limit the capacity of a slice.

make(): Preallocate the backing array Preview 09:22

Understand when to and how to use the make function to pre-allocate backing arrays for slices.

copy(): Copy elements between slices Preview 07:39

  • You will learn how to copy the slices without using a loop.

  • You will learn when to and how to use the copy function.

How to use multi-dimensional slices? Preview 09:18

  • You will learn how the multi-dimensional slices work.

  • You will understand their differences than multi-dimensional arrays.

  • You will learn how to initialize inner slice elements using the make function.

Prove Yourself: Advanced Slice Operations

★ ADVANCED SLICE OPS EXERCISES ★ Preview 00:48

Build an Empty File Finder Program Preview 00:16

Fetch the Files Preview 05:27

You're going to learn:

  • How to get the names of all the empty files from a directory

  • This is the first part of the project, in the next lecture, you're going to use the append function to write the names of the empty files to a file.

Write to a file Preview 04:28

You're going to learn:

  • How to write to a file using a byte slice

  • How to calculate file permissions using octal numbers

Optimize! Preview 04:15

We're going to optimize the program using the make function.

★ FILE FINDER EXERCISES ★ Preview 00:07

Project: Animate a Bouncing Ball Preview 00:29

Challenge Preview 04:10

  • Let's learn what the bouncing ball program is going to look like.

Challenge Document Preview 01:32

Step #1: Create and Draw the Board Preview 06:26

  • Learn how to draw the board using a multi-dimensional slice

Step #2: Optimize by adding a Buffer Preview 07:02

  • Learn how to optimize the program adding a slice as a buffer

  • How to add a buffer and reuse it instead of doing a lot of system calls

  • How to simply measure the execution speed of a program

Step #3: Animate the Ball Preview 06:21

  • Calculate the ball position using velocity and collision detection

  • Complete the program by animating the ball

★ BOUNCING BALL EXERCISES ★ Preview 00:35

Learn how to encode and decode UTF-8 strings Preview 00:13

Introduction and Roadmap Preview 01:22

★ Resources ★ Preview 00:22

Let's learn the basics of bytes, runes and strings Preview 03:36

  • What is a string, really?

  • []byte to string conversion

  • Binary and hexadecimal numbers

Let's write a character-set program Preview 06:44

  • Build a character-set printer program so that you can intuitively understand how the Unicode code points work

  • Learn about the special Printf verbs to print code points

Let's convert, index, and slice bytes, runes and strings Preview 11:27

  • Immutable strings

  • Slicing and Indexing strings

  • Convert a string value to []byte and []rune to manipulate it

  • Learn how to get the runes of a string using its bytes

  • Learn about utf8 package's RuneCountInString and RuneCount functions

  • Learn about the ups and downs of using a []rune instead of []byte or string

How can you decode a string? Preview 07:48

Learn about:

  • How decoding works

  • How to manually decode a string

  • When to use utf8 package's DecodeRune and DecodeRuneInString functions instead of for range

String Header: Why strings are immutable? Preview 08:15

Learn about:

  • Why strings are immutable?

  • Why slicing a string is an efficient operation?

  • What does a string value looks like behind the scenes?

Recap: Strings Revisited Preview 01:40

Prove Yourself: Strings, Bytes, and Runes

★ UTF-8 EXERCISES ★ Preview 00:04

Project: Let's Build a Spam Masker Preview 00:08

Challenge Preview 03:04

Let's create a program that efficiently masks the spam links in a text by directly manipulating the bytes.

Challenge Document Preview 00:53

Detect the link patterns Preview 05:03

  • String concatenation vs using a byte buffer

  • Detect link patterns inside the text by manipulating the bytes

Mask the links Preview 06:17

  • Learn about a special case for the append function for string values

  • Masks the links inside the text

  • Detect whitespaces by comparing the bytes and disable the masking when necessary

  • Manipulate the byte buffer directly instead of appending to it

★ Text Wrapper Challenge ★ Preview 00:43

Let's build a Unicode text wrapper Preview 06:01

  • Understand how to work with unicode strings

Learn Go's Maps and Internals Preview 00:09

Create an English to Turkish dictionary Preview 08:28

  • English to Turkish Dictionary Example

  • What's a map and why you might want to use one?

  • Map keys and comparability

  • Comparing map values

  • Slices vs Maps

Populate the dictionary Preview 08:13

  • How initialize a map?

  • How to change a map element?

  • How to detect whether a key exists or not? (Comma-OK idiom)

  • How to range over a map?

  • How to compare maps using Sprintf?

Map Internals: How maps work behind the scenes? Preview 10:45

  • Learn the map internals: How they work behind the scenes?

  • The differences between a map and a slice value.

  • Properly cloning a map

  • Create a map using the make function

  • What's the importance of the size parameter?

  • How to delete map keys?

  • Learn how to remove a map completely from memory.

Prove Yourself: Maps

★ MAP EXERCISES ★ Preview 00:10

Scan for Input using bufio.Scanner Preview 00:07

Scan user input using bufio.Scanner Preview 07:07

  • Create a program that counts the number of lines from any input stream.

  • What is input scanning and how to scan for input?

  • How to use bufio.Scanner?

Use maps as sets Preview 09:22

  • Create a program that can search words in Shakespeare's Romeo and Juliet.

  • How to search words from a website content.

  • How to work with regular expressions.

  • How to redirect input to something else.

  • How to use a map as a set.

  • Using bufio.Scanner: How to scan for words instead of lines.

Create a Log Parser using maps and bufio.Scanner Preview 07:39

  • Create a log parser program that can summarize the number of visits per domain.

  • How to handle errors when the input data is incorrect.

Prove Yourself: Input Scanning

★ SCANNER EXERCISES ★ Preview 00:30

Structs: Organize Data Preview 00:09

What is a struct? Preview 04:33

  • What is a struct? Why?

  • The differences between struct types and struct values.

  • Slices, maps vs Structs

  • Struct type defitinion and struct literal.

Let's create a struct! Preview 07:40

  • Variables vs Structs.

  • Struct printing tricks.

  • Struct zero-value.

  • Creating new struct types and values.

  • Importance of struct field names.

When can you compare struct values? Preview 08:11

  • When can you compare struct values?

  • How the struct comparison works behind the scenes?

  • Create a music playlist.

Go OOP: Struct Embedding Preview 06:46

  • Inheritance vs Composition

  • Anonymous and Promoted Fields

  • Composing structs with embedding

Rewrite: Log Parser to Structs Preview 05:44

  • Learn how to add structs to an existing program.

  • What is an addressable value?

  • Why is it not possible to access the address of the original map elements?

Encode values to JSON Preview 09:11

  • Marshaling: How to encode to JSON?

  • Exported and Unexported fields

  • Struct Tags (Field Tags)

  • Intro to JSON

Decode values from JSON Preview 06:42

  • Unmarshaling: How to decode from JSON?

  • Get data from a json file using bufio.Scanner

  • Brief intro to pointers

Prove Yourself: Structs

★ STRUCT EXERCISES ★ Preview 00:18

Functions: The Building Blocks Preview 00:15

Learn the function basics Preview 09:35

  • Learn the function declaration syntax.

  • Learn about the function scopes.

  • Why shouldn't you declare variables at package-level?

  • How to run multiple files?

Confine variables to a function Preview 10:06

  • Why should you confine variables to a function?

  • How to chain functions?

  • Funcs that return errors

  • Single and multiple input funcs

  • Single and multiple result funcs

Rewrite: Log Parser using functions Preview 08:11

  • Learn how to split a program into functions

  • Learn about the named result values and naked returns

  • Learn how to use structs with functions

Learn the Pass By Value Semantics Preview 07:58

  • Refactor the Log Parser program

  • Learn everything about pass-by-value semantics

  • Implications of passing structs, maps, and slices to functions

  • The differences between passing a map and a slice to a function

Prove Yourself: Functions

★ FUNC EXERCISES ★ Preview 00:27

Pointers: Indirectly update data Preview 00:12

What is a pointer? Preview 10:55

  • What is a pointer, dereferencing, taking an address?

  • Learn about pointer types and pointer variables

Learn the pointer mechanics Preview 10:15

  • Learn pointer mechanics by examples

  • The address operator

  • Deferencing a pointer

  • Printing the memory addresses

Learn how to work with pointers to composite types Preview 08:01

  • Learn the basics of passing pointers to composite types.

  • Automatic dereferencing

  • Pointers to arrays

  • Pointers to slices

  • Pointers to maps

  • Pointers to structs

Rewrite the Log Parser using Pointers Preview 06:37

  • Learn how to design a program using pointers.

  • The differences between value and pointer semantics.

  • What is addressability?

Pointers or Values? Be Consistent Preview 07:24

  • Where and why might you want to use pointer types instead of value types?

  • Why you should be consistent?

Prove Yourself: Pointers

★ POINTER EXERCISES ★ Preview 00:20

Methods: Grab the code Preview 00:10

Methods: Enhance types with additional behavior Preview 11:02

  • Understand what a method is.

  • Understand the differences between a method and a function.

  • The method syntax.

  • The value receiver.

  • How to name receivers and methods correctly.

Pointer Receivers: Change the received value Preview 10:28

  • Understand what a method really is.

  • How to work with pointer receivers?

  • When to use a pointer receiver?

  • The impact of value receiver on the program performance.

  • Automatic dereferencing.

  • Importance of consistent receivers.

Non-Structs: Attach methods to almost any type Preview 07:54

  • Can you attach methods to all the types in Go?

  • What's the difference of Go from other OOP languages?

  • Learn to attach methods to non-struct types

  • Attach methods to types on the fly

  • Create a slice type with methods attached

  • Create a money type with methods attached

  • Learn to work with nil receivers

Interfaces: Grab the code! Preview 00:15

Interfaces: Be dynamic! Preview 11:37

  • What is an interface?

  • How to declare and when to use an interface?

  • Abstract vs Concrete Types.

  • Comparing interface values.

  • Interface satisfaction.

Type Assertion: Extract the dynamic value! Preview 11:48

  • What is a type assertion?

  • Interface internals: Dynamic value and type.

  • How to extract the dynamic value from an interface value using the dynamic type?

  • How to assert behavior using interfaces?

Empty Interface: Represent any type of value Preview 10:25

  • What is an empty interface?

  • When and how to use it?

  • Famous Gotcha: []interface{} vs interface{}

  • Unix timestamps example using empty interfaces.

  • Bonus: Go time layout format.

Type Switch: Detect and extract multiple values Preview 06:27

  • What is a type switch?

  • When and how to use it?

  • Type assertion vs Type switch.

  • value.(type) and var := value.(type) syntax.

  • Bonus: Go time.Time layout format.

Promoted Methods: Let's make a little bit of refactoring Preview 09:32

  • What is a promoted method? How and when to use it?

  • How to work with promoted methods and interfaces.

Famous Interfaces: Grab the code! Preview 00:33

Don't interface everything! Preview 11:45

  • Should you use interfaces all the time? Are there alternative ways?

  • Let's simplify the project by getting rid of the interface.

  • Create a new timestamp type that formats timestamp values by embedding a time.Time value.

Stringer: Grant a type the ability to represent itself as a string Preview 09:46

  • The benefits of satisfying common interfaces.

  • How to use and satisfy the fmt.Stringer?

  • Learn how to work with the strings.Builder type.

Sorter: Let a type know how to sort itself Preview 09:50

  • How to customize sort.Sort by implementing the sort.Interface?

  • How to create custom sorters using anonymous embedding.

Marshalers: Customize JSON encoding and decoding of a type Preview 08:39

  • How to customize the JSON encoding and decoding?

  • Learn when to use Marshaler and Unmarshaler interfaces.

  • Make the timestamp type a JSON marshaler and unmarshaler.

  • BONUS: log.Fatal and strconv.AppendInt.