We may earn an affiliate commission when you visit our partners.
Tony de Araujo

Welcome to The Go Language Lecture Series.

In this third volume, we delve into essential topics that will enhance your understanding of Go. We will review critical topics from previous volumes and quickly get into new material. Here's a list of the areas we will be covering. It's over 4 hours of essential Go exercises for practicing, learning, and reviewing:

Read more

Welcome to The Go Language Lecture Series.

In this third volume, we delve into essential topics that will enhance your understanding of Go. We will review critical topics from previous volumes and quickly get into new material. Here's a list of the areas we will be covering. It's over 4 hours of essential Go exercises for practicing, learning, and reviewing:

  1. Blank Identifier: A reintroduction to this powerful tool and how to use it.

  2. Datatype Inference and Zeroed Values: Understand how Go infers types and initializes variables.

  3. Creating Custom Data Types: Learn how to define your own structures and types.

  4. Type Aliases in Go: Simplify complex type names.

  5. For Range Loop: A deeper exploration of this versatile construct.

  6. Importing useful packages from GitHub.

  7. Struct Datatype: Dive into structs with practical exercises.

  8. Interfaces Applied to Structs: Unleash the power of interfaces.

  9. Map Data Types: Master maps for efficient data storage.

Expect quick drills that target specific concepts, as well as repetitive tips to cement important ideas. Whether you spend four hours or several weeks, this volume is a valuable resource. Use it for reviewing during your own projects, we will keep it updated and add more details over time.

Let’s embark on this learning journey together.

Enroll now

What's inside

Learning objectives

  • Introduction to golang structs, maps, interfaces, variadic arguments
  • The project is designed for both learning or reviewing. videos are self-contained.
  • This course can coexist with other go courses. it will help you understand syntax.
  • Volume 3 reviews some concepts from previous volumes and adds more advanced syntax.

Syllabus

A few notes and some review

Hello and thanks for your interest on the exercises that follow. We will begin with a reintroduction to the blank identifier, moving next to datatypes, inference, and zeroed values. Then, we will see how to create our own datatypes, as well as how to create type aliases in Go. Next, we will reintroduce the range loop, and move quickly to struct datatypes where we will do multiple exercises to illustrate specific concepts that we must know. After structs we will work with Interfaces as applied to structs. And later we will add map datatypes to the mix. Then finally, we will do several exercises with interface parameters as applied to strings, numbers, maps, slices, and variadic functions. This volume is packed with simple, quick exercises, targeting specific concepts we must know and should review periodically. Let's begin, my friend. I'll see you on the next session. Thank you.

Read more
Using the official Go Playground

Reintroducing the blank identifier in Go.

A general review of datatypes, type inference, and default values in Go.

Introduction to customized data types in the Go language.

Exercise result: Creating your own data types

The difference between own-type and type-alias. How to display the type of  variable to screen in Go.

For range loop review and additional information.

Optional exercise – for range loop
A tutorial on how to create customer types in the Go programming language and how to use them.

Introduction to structs in the Go language. What are structs, how to declare a basic struct, introduction to fields, datatypes, and a function receiver example.

How to declare a variable of type struct and add values to it.

How to include values at the time of a struct variable declaration. How to skip values or reorder values at declaration.

Go accepts leading commas in literal value declarations. When to use them and why.

Optional exercise – create a struct

How to create an anonymous struct to be used in a single variable declaration.

Quick review of struct variable declarations. Also, how to declare a struct using function new versus asterisk.

Optional exercise: pointing to an anonymous struct. Also, dereferencing the data

How to address field values in a struct of type array or slice. Syntax and looping ideas.

Structs - Optional exercise: Practicing exercise based on the last video
Structs - Solution for the previous structs exercise

How to create a function to edit structs in Go. Introducing the receiver parameter, which replaces the "this" keyword from other languages.

Structs - Solution for the last exercise
Optional exercise: function to change value in a struct

How to create a Go method without using a receiver. What is early binding versus late binding.

This exercise demonstrates that in Go, receiver parameters can accept variables of a designated type, or pointers to variables of the same type. This flexibility is not available on regular function parameters.

This exercise demonstrates how function receiver parameters only accept types that reside locally. It illustrates the concept without unnecessary jargon.

Optional exercise: Adding a local type to a receiver parameter

Go does not support function overloading in its traditional sense. We can however, emulate overloading by using different receivers. Function overloading is when we use the same name for functions that accomplish different things.

Go does not support inheritance or sub classing. Instead, it promotes what is called implicit delegation. The term delegation, in generally, refers to when one entity, such as a struct, for example, passes something to another entity, like delegating its fields to another struct. Trough delegation we can, in our example here, use the fields from struct Person in Student instead of rewriting similar fields.

Optional exercise: Implicit field delegation in structs

Delegating structs also delegates their methods. Delegated methods can be overridden.

How to override delegated fields in a Go struct. Also assigning fewer fields upon variable declaration.

How to loop over the fields in a Go struct.  How to import a package from Github.

Practicing exercise: How to declare a range loop to iterate over a Go struct.

Solution for the previous exercise: how to declare a range loop to iterate over a Go struct.

How to include a function as a value in a Go struct field.

0:00… How to see if a field is "empty".
2:02… How to compare two structs.
3:08… How to see if a struct has own values.
4:49… How use "reflect" to compare structs at runtime.

Optional exercise: Taking AI for a spin

Congratulations for finishing the structs exercises or even returning to review these concepts periodically. We could go on and on with structs, but we also need to stop somewhere and visit other data structures, which will help us better understand the ones we already know so far. Knowing several data structures permit us to use structs in more complex outcomes. Before we go, let's review the commons ways for declaring a variable of type struct

A metaphorical view of what an interface is in the Go language as well as the requirements for membership.

What is the benefit of subscribing a given interface?

How to declare an interface, a function router method, and and to put it to use. The last downloadable file contains the complete code.

How do we add a return value to interface member functions in the Go language? The function signature of member functions must match the function signature listed in the interface.

How to add arguments to interface member functions. How to accept different datatypes when calling the same function. The empty interface quick introduction.

INTERFACES/Structs - Please check your understanding

How to declare a slice of type interface to gather all members and loop their content to screen.

Optional exercise (part 1) - interfaces/structs
Optional exercise (part 2 ) - interfaces/structs
Optional exercise (part 3) - interfaces/structs

Congratulations and where we go from here.

Introduction to maps in Go. The difference between a struct and a map. When to use a map, a slice, or a struct.

How to declare a map container by using the make function. How to assign values to a map.

How to declare a map container with literal values. Reviewing leading commas in Go.

How to add new items to a map. How to edit or delete existing items from a map.

How to use the blank identifier to ignore a variable in a tuple assignment. How to temporarily ignore an imported package. How to declare a variable without having to use it in the executable code.

Ho to verify if an item exists in a Go map. The comma ok pattern.

How to loop over a map using a for range loop. This creates an unsorted output. See next session for a way to sort the output.

How to sort the keys in a map for displaying purposes. The sort package, the Strings and Ints functions. Creating a slice of map keys.

Optional exercise: sorting a map keys result
Optional bonus exercise: Sorting the values of a map

Hoe to change the name of a key in a Go map. Also introduction to map length and map capacity.

Optional exercise: renaming a key in a map

Introduction to interfaces as parameters. The empty interface.

Optional exercise: Adding an interface parameter to a function
Interface parameters - Type assertion intro
Optional exercise: getting an integer from an interface parameter

Ho to assert an argument from an interface parameter to prevent a datatype error. The comma ok pattern.

Quick review: using the comma ok pattern

How to display the asserted argument from an interface parameter, or an alternative message if the argument is invalid.

Optional exercise: Writing a more idiomatic if statement

How to fork your function code based on the datatype being submitted. Introducing the type keyword and  switch mechanism.

Optional exercise: converting a type assertion into a switch type assertion

How to check for a datatype in an interface parameter from multiple possibilities, using the switch mechanism.

How to pass a map datatype to a function via an interface parameter and how to describe the map in a switch construct.

How to submit an indefinite number of variables to a function even if those variables are of  different datatypes. Introducing variadic function parameters for single types or interfaced types.

Optional exercise: unpacking a variadic interface parameter

How to loop over variadic arguments to display values. Why these values cannot be used in calculations because they have not been asserted.

How to assert arguments while traversing a variadic parameter using a range loop.

How to pass a slice as an argument to a variadic parameter. How to assert a slice type.

Congratulations, my friend. Please revisit often.

Good to know

Know what's good
, what to watch for
, and possible dealbreakers
Reviews blank identifiers, datatype inference, and zeroed values, which are essential for understanding how Go works and are often a source of confusion for newcomers
Explores structs, interfaces, and maps, which are fundamental data structures in Go and are used extensively in real-world applications
Covers type aliases, which can simplify complex type names and improve code readability, especially when working with nested or generic types
Includes exercises on importing useful packages from GitHub, which is essential for leveraging external libraries and tools in Go projects
Requires learners to have prior exposure to Go, as it builds upon concepts from previous volumes and introduces more advanced syntax
Focuses on quick drills and repetitive tips, which may not suit learners who prefer a more in-depth and theoretical approach to learning

Save this course

Save The Go Language: Structs, Maps, Interfaces, and Exercises to your list so you can find it easily later:
Save

Activities

Be better prepared before your course. Deepen your understanding during and after it. Supplement your coursework and achieve mastery of the topics covered in The Go Language: Structs, Maps, Interfaces, and Exercises with these activities:
Review Go Basics
Solidify your understanding of Go fundamentals before diving into structs, maps, and interfaces.
Browse courses on Go Programming
Show steps
  • Review basic syntax and data types.
  • Practice writing simple Go programs.
  • Familiarize yourself with Go's package management.
Read 'The Go Programming Language'
Deepen your understanding of Go concepts with a comprehensive guide.
Show steps
  • Read the chapters related to data structures and interfaces.
  • Work through the examples provided in the book.
  • Try implementing your own data structures based on the book's explanations.
Implement Structs and Methods
Reinforce your understanding of structs and methods through hands-on coding exercises.
Show steps
  • Create different structs with various fields.
  • Implement methods for these structs to perform specific actions.
  • Test your structs and methods thoroughly.
Four other activities
Expand to see all activities and additional details
Show all seven activities
Read 'Effective Go'
Learn best practices for writing Go code from the official Go documentation.
Show steps
  • Read the sections related to data structures and interfaces.
  • Pay attention to the examples and explanations of idiomatic Go code.
  • Apply the principles of Effective Go to your own projects.
Blog Post: Go Maps vs Structs
Solidify your understanding of maps and structs by explaining their differences and use cases in a blog post.
Show steps
  • Research the key differences between maps and structs.
  • Write a blog post explaining these differences with examples.
  • Publish your blog post online.
Build a Simple CRUD Application
Apply your knowledge of structs, maps, and interfaces by building a CRUD application.
Show steps
  • Design the data model using structs.
  • Implement CRUD operations using maps or a database.
  • Create interfaces for data access and manipulation.
Help others in online forums
Reinforce your understanding of Go by helping others learn.
Show steps
  • Find online forums or communities where people are learning Go.
  • Answer questions and provide guidance to other learners.
  • Share your knowledge and experience with Go.

Career center

Learners who complete The Go Language: Structs, Maps, Interfaces, and Exercises will develop knowledge and skills that may be useful to these careers:
Golang Developer
A Golang developer specializes in building applications using the Go programming language. This course teaches structs, maps, interfaces, and practical exercises, all of which are important concepts for a Golang developer to master. These concepts are central to writing efficient and effective code. By understanding how to create custom data types and implement interfaces, a Golang developer can produce high-quality applications. A Golang developer will benefit greatly from the hands-on approach of this course. This course in particular is valuable because it goes beyond simple syntax and introduces more advanced concepts. The repetitive tips throughout the course reinforces the core knowledge.
Software Engineer
A software engineer often works with data structures and algorithms to build applications. This course, with its deep dive into Go's structs, maps, and interfaces, helps build a foundation for this work. The course's exercises on creating custom data types and applying interfaces to structs directly applies to software development. The course also helps those who may want to specialize in building Go-based applications. A software engineer will benefit from the practical exercises in the course, helping to build a deeper understanding of these core concepts. Understanding how to implement these concepts will help in the day-to-day work, from designing new features to debugging existing code. The course's focus on hands-on learning with repetitive tips will be essential to this goal.
Backend Developer
Backend developers build and maintain the server-side logic of applications. This course on Go language, with its focus on structs, maps, and interfaces, is an important tool for backend development with Go. The course helps build a foundation in data handling and manipulation through its exploration of Go's data types and structures. A backend developer uses these tools to create efficient code for the server side. The course's focus on practical exercises, especially in areas such as map data types and interfaces, provides tangible skills they can use in their everyday work. Learning how to create custom data types and use Go's type system will help a backend developer improve the quality of their code.
Systems Programmer
A systems programmer creates low-level software that interacts with hardware. This course, which covers core topics in the Go language like structs, maps, and interfaces, helps build a foundation for this career. The exercises in the course, particularly those working with custom data types and how to use interfaces, will be useful in building efficient, reliable software for interacting with hardware. A systems programmer will use these skills in designing system-level tools and software components. The course’s focus on practical exercises and repetitive tips help ensure mastery of the concepts and syntax. This is useful when one needs to debug low-level code.
Cloud Engineer
Cloud engineers build and maintain cloud infrastructure. The skills taught in this Go language course, particularly around data types and structures, are very relevant for a cloud engineer. The course’s focus on structs, maps, and interfaces will help cloud engineers to build and manage cloud resources. This course will give an understanding of how to manage data through the use of Go. A cloud engineer will benefit from learning how to create custom data types and make use of interfaces. The course is packed with simple and quick exercises, targeting specific concepts, which is a great way to prepare for the challenges of building cloud solutions.
API Developer
An API developer builds application programming interfaces that allow different applications to communicate. This course on the Go programming language, especially the in-depth coverage of structs, maps, and interfaces, may be useful to an API developer. These are important concepts to build efficient and maintainable APIs. The course helps to build a foundation in these core techniques. An API developer will use these tools to design and implement effective APIs. The practical exercises in this course, such as those involving range loops and custom data types, create a deeper understanding of the tools. In particular, this course’s constant review of important ideas will be valuable for a working professional.
Data Engineer
A data engineer builds the infrastructure for data storage and processing. This course, with its focus on data structures like structs and maps in the Go language, may be useful for a data engineer. The course’s exercises on type inference and custom data types may help a data engineer in managing data efficiently. A data engineer will need to understand how to work with different data types. The course's focus on practical exercises helps to build a foundational understanding of these concepts. The course goes over a wide variety of common use cases, making it practical for engineers.
DevOps Engineer
A DevOps engineer works to bridge development and operations, often using automation tools and scripting. While not directly mentioned, this course on Go programming may be useful for a DevOps engineer, as Go is often used for building command line tools and automation scripts. The course's focus on data manipulation using structs and maps provides skills used in DevOps. A DevOps engineer might use the concepts learned to automate tasks and manage configurations. Practical exercises, especially those involving interfaces, may be useful. The course goes over many different use cases of these concepts, which a DevOps engineer can use or adapt to new applications.
Embedded Systems Engineer
An embedded systems engineer designs and develops software for embedded devices. This job may be suited to those taking this course. While not a primary focus, the Go language offers many advantages for certain embedded systems. Therefore, a course that explores Go data structures, like structs and maps, may be useful for understanding how to manage data in the embedded realm. An embedded systems engineer can use the knowledge of custom data types taught in this course to optimize memory usage. The repetitive exercises in the course may be helpful in building the necessary precision for working in a detail-oriented field like this one.
Technical Lead
A technical lead provides guidance and technical direction to a development team. While this course focuses on the technical aspects of the Go language, a technical lead may find the knowledge of structs, maps, and interfaces useful for guiding junior developers. The detailed explanations in the course can serve as a reference for complex concepts. A technical lead will likely have to review code and make decisions about architecture. The course may be useful for ensuring that the technical lead is familiar with the specific technical details of this project. This is particularly helpful for maintaining code quality and consistency. Even if the technical lead does not write Go every day, a deep understanding of the language is helpful.
Software Architect
A software architect designs the high-level structure and components of software systems. This course covers fundamental building blocks of the Go language, like structs, maps, and interfaces, which may be useful for a software architect to know. The course's in-depth look at these concepts helps the software architect make informed decisions about technical implementation. A software architect must grasp how different data structures can be used to optimize system design. The course’s exercises can help build the necessary expertise to make these decisions. While a software architect may not write extensive code every day, having a firm understanding of the language is useful.
Solutions Architect
A solutions architect designs and implements technology solutions to meet business needs. While this course focuses on the technical aspects of the Go language, a solutions architect may need to know these concepts in order to recommend the right technology. The course's emphasis on practical exercises helps a solutions architect get familiar with the technologies. The detailed overview of custom data structures means that a solutions architect with a background in Go will be able to better evaluate solutions. The course's broad overview of interfaces may also be useful for those in this role.
Database Administrator
A database administrator manages and maintains databases. While not directly related, this course on the Go language might be useful if the database administrator is also required to write custom tools using Go. The course's focus on data structures, such as maps and structs, may be useful for manipulating data in these tools. A database administrator, in some contexts, is asked to write code for data migration or creating custom utilities. The course may be useful for these secondary tasks. The course's repetitive exercises may help those who use Go infrequently to get up to speed quickly.
Technical Project Manager
A technical project manager oversees software projects, often requiring an understanding of the underlying technologies. This course, focusing on structs, maps, and interfaces in the Go language, may provide a project manager with a degree of insight into the technical work. This will allow them to better understand the challenges the team faces. A technical project manager may review code and make decisions about the project’s direction. The course's detailed breakdown of complex topics may be useful to help a technical project manager better understand this language, and thereby, improve their team’s performance. A strong technical understanding makes it easier to manage engineering teams.
Quality Assurance Engineer
A quality assurance engineer designs and implements tests for software applications. While not a direct fit, this course on the Go language may be useful to a quality assurance engineer, particularly if they need to work with Go-based applications. The course’s exploration of data structures and interfaces may be useful for understanding how to test these aspects of software. A quality assurance engineer may also develop test tools using Go. The repetitive exercises in this course may be useful in rapidly developing familiarity with the specifics of this language.

Reading list

We've selected two books that we think will supplement your learning. Use these to develop background knowledge, enrich your coursework, and gain a deeper understanding of the topics covered in The Go Language: Structs, Maps, Interfaces, and Exercises.
Comprehensive guide to the Go programming language, covering everything from basic syntax to advanced topics. It provides a solid foundation for understanding Go's features and best practices. It is particularly useful for understanding the underlying principles behind structs, maps, and interfaces. This book is commonly used as a textbook at academic institutions.
Effective Go is not a book, but rather a document provided by the Go team. It provides guidance on writing clear, idiomatic Go code. It is particularly useful for understanding how to use structs, maps, and interfaces in a way that is consistent with Go's design principles. This is more valuable as additional reading than it is as a current reference.

Share

Help others find this course page by sharing it with your friends and followers:

Similar courses

Similar courses are unavailable at this time. Please try again later.
Our mission

OpenCourser helps millions of learners each year. People visit us to learn workspace skills, ace their exams, and nurture their curiosity.

Our extensive catalog contains over 50,000 courses and twice as many books. Browse by search, by topic, or even by career interests. We'll match you to the right resources quickly.

Find this site helpful? Tell a friend about us.

Affiliate disclosure

We're supported by our community of learners. When you purchase or subscribe to courses and programs or purchase books, we may earn a commission from our partners.

Your purchases help us maintain our catalog and keep our servers humming without ads.

Thank you for supporting OpenCourser.

© 2016 - 2025 OpenCourser