Table of Contents
IntroductionMaximiliano Firtman introduces the course by sharing some personal and professional background. The overview includes key topics covered, such as Go fundamentals, standard libraries, goroutines, the fmt package, the http package, templating, and web servers, providing a clear outline of the course content.
What is Go
The History of GoMaximiliano provides a brief overview and history of Go including its connection to Golang. The discussion highlights the three main goals of the Go language: ease of coding, efficient compilation, and efficient execution.
Characteristics & TimelineMaximiliano explores the key characteristics of Go, such as its static type system, garbage collection, and single binary compilation. The discussion also includes an overview of the timeline of Go, starting from its inception in 2007 to the release of Go 1.20 in 2023, providing a glimpse into the evolution of the language over time.
Go.dev OverviewMaximiliano guides students through the official Go website and explains the organization of its documentation. The discussion includes a brief demonstration of the Tour of Go tutorial and an overview of the learning resources available.
Philosophy & ToolsMaximiliano explores companies that use Go and the main values of the language. The discussion also covers the capabilities of the Go CLI and the tooling required for developing Go applications.
Go SetupMaximiliano walks through selecting the appropriate Go extension for Visual Studio Code, checking Go installation, and creating a basic stand-alone Go script. The discussion also covers how to run the Go script from the terminal.
Multi Platform & Common Use CasesMaximiliano explores the multi-platform capabilities of Go, highlighting its ability to generate executable binary files for various platforms and operating systems. The discussion further covers common use cases for Go, such as web services, DevOps, desktop UI, and machine learning.
Variables, Constants, and Data Types
Go Basics OverviewMaximiliano discusses fundamental syntax rules of Go, emphasizing the use of curly braces to contain code blocks, the case-sensitivity of the language, and its non-object-oriented nature without classes. The discussion further covers essential rules governing the contents of folders and files in Go.
Create a Go ModuleMaximiliano showcases the process of creating and running a module using the Go command-line interface (CLI). The discussion also covers the topic of creating multi-module applications using workspaces.
Variables, Types & ConstMaximiliano explains the syntax for defining variables, constants, and data types in Go. The discussion also highlights Go's capability to infer data types and introduces a shortcut for defining variables.
Data TypesMaximiliano demonstrates Go's pre-defined data types, including strings, booleans, and numeric types like integers and floating-point values. The discussion also addresses student questions about defining constants globally and Go's ability to automatically determine a variable's data type.
PackagesMaximiliano covers the topic of defining and importing packages in Go, explaining the scope of functions within these packages. The discussion includes a demonstration using dot syntax to access data from imported packages and how to define public or private visibility.
Packages Q&AMaximiliano demonstrates helpful functionality in VS Code for importing packages and performing linting in Go development. The discussion also covers a student's question about exporting data from packages other than the main package.
VisibilityMaximiliano gives a concise overview of visibility in Go, explaining the concepts of defining public or private elements and discussing the various scoping options for variables and lambda functions.
Numbers & CollectionsMaximiliano explores the usage of global functions for converting between different number types in Go, and introduces collections such as arrays, slices, and maps. It is important to note that collections in Go are not objects and can be manipulated using global functions.
Functions, Control Structures, & Error Handling
FunctionsMaximiliano highlights the characteristics of functions in Go, emphasizing their capability to return multiple values and use labeled variables. The segment includes a demonstration of how to handle functions that return multiple variables.
Pointers & ReferencesMaximiliano showcases the usage of pointers in Go, which allows creating references to the original value of a passed variable. It's important to note that unless a reference is used, Go automatically creates a copy of the passed variable.
panic, defer, & Error Design PatternMaximiliano demonstrates Go's less common control flow mechanisms, panic and defer, along with design patterns for error handling. These mechanisms involve triggering runtime errors, halting program execution, and deferring function evaluations.
Calculator ProjectMaximiliano guides you through the process of creating a basic calculator in Go, which takes input from the standard input using Scanf. Additionally, different verb types for the fmt package functions are explained in this segment.
Reading FilesMaximiliano showcases the usage of os.ReadFile to read the contents of a text file, and provides guidance on handling errors that may occur during a failed read attempt.
Writing FilesMaximiliano illustrates the process of writing a file using os.WriteFile and creating more intricate messages with fmt.Sprintf. The segment also addresses a student's question about whether package names and directories must match.
Type Definitions, Structures, & Interfaces
Type DefinitionsMaximiliano showcases the declaration of new types, the addition of methods to types, and referencing types using aliases. However, it is important to note that methods cannot be attached to type aliases.
Type Definitions Q&AMaximiliano addresses a student's question about defining methods with string types and provides an additional example that demonstrates defining types with an attached method to clarify the purpose of the attribute arguments.
StructsMaximiliano explores structures, which are data types that have strongly typed properties, default constructors, and the ability to include methods.
Struct MethodsMaximiliano demonstrates creating a data structure and explains how to import and access the structure data in a different package. It is important to make the properties of the data structure public in order to access them.
FactoriesMaximiliano showcases patterns for creating factory functions that generate instances of structs or interfaces. These factory functions encapsulate the creation logic and offer a convenient way to construct instances of complex or customizable types.
Implementing the Stringer InterfaceMaximiliano demonstrates implementing a method that modifies the default output of a type to a customized string format.
EmbeddingMaximiliano showcases type embedding, allowing the parent type to inherit the properties of the embedded type. The segment also covers accessing the embedded data in a factory function.
InterfacesMaximiliano demonstrates how to create interfaces in Go, which define a set of methods that can be used as a type. Interfaces in Go have implicit implementation and can emulate polymorphism commonly found in object-oriented programming.
GoroutinesMaximiliano discusses goroutines, which are Go's way of utilizing threads, and demonstrates how to open a goroutine using the "go" prefix. This segment also covers delaying thread execution using time.Sleep.
ChannelsMaximiliano demonstrates creating channels for inter-goroutine communication and addresses a student's question about passing channels between multiple packages. Buffer channels are also introduced to control the number of values that can be sent at once.
Creating an API Client
Crytpomasters SetupMaximiliano walks through setting up the initial packages for a console application that utilizes the cex.go package to make API requests and retrieve data.
Making an HTTP RequestMaximiliano demonstrates the usage of the strings package to perform basic operations on UTF-8 encoded strings, such as manipulation and transformation. It's important to note that these functions generate a new copy of the string and do not modify the original.
Response & Error HandlingMaximiliano showcases the creation of response and error handlers using the built-in HTTP status codes provided by the Go http package. These handlers are useful for managing and handling various HTTP responses and errors in a Go application.
Printing The API ResponseMaximiliano demonstrates how to make an API call from the main package and showcases the format of the returned data.
JSON Parsing with UnmarshalMaximiliano demonstrates the process of parsing and storing JSON data using the Unmarshal function from the json package. The Unmarshal function decodes the JSON-encoded data and saves the result in the provided value, which should be a pointer.
Mapping Between JSON and Go StructMaximiliano creates a Go struct that aligns with the API's JSON response structure, using a JSON-to-Go converter tool. It emphasizes that if the property types in the struct do not match the JSON data, the Unmarshal function will raise an error.
WaitGroupsMaximiliano illustrates that the order of API data returned from a Get call is a synchronous operation. Additionally, the segment discusses utilizing waiting groups to wait for a collection of goroutines to finish.
Async API Calls with GoRoutinesMaximiliano demonstrates the creation of a lambda function that functions as a GoRoutine, allowing for the containment and synchronous execution of API calls. This approach enables efficient handling and coordination of API requests within the Go program.
TestingMaximiliano explores Go's built-in testing capabilities, including defining test suites, testing functions, and Go fuzzing. Fuzzing, a form of automated testing that systematically manipulates program inputs to uncover bugs, is also covered in this segment.
Creating a Server
Logging & Watching for ChangesMaximiliano addresses a student's question about enabling debugging and demonstrates the process of moving the server function outside of the main function. The segment also mentions that Go does not provide a built-in tool for automatically restarting the server when a file changes, requiring the use of a third-party tool.
Serving FilesMaximiliano demonstrates the usage of the FileServer utility function to create a file server that automatically searches the specified directory for files to be served.
Go TemplatesMaximiliano explores the usage of Go templates for server-side rendering, emphasizing their ability to generate dynamic content like HTML or configuration files. By separating the presentation logic from the data, Go templates facilitate easier management and updates.
Serving from Data StructuresMaximiliano responds to student inquiries about the required imports and clarifies whether the dot in the template represents a type. Additionally, the segment includes a demonstration of serving a museum exhibition from a data structure.
Template Looping & Conditional HTMLMaximiliano showcases the usage of the range keyword to iterate over the existing data structure and dynamically render the remaining museum exhibitions. The segment also covers the conditional rendering of HTML using if-else statements.
API Handlers for GETMaximiliano illustrates the process of creating handlers to make API GET requests and retrieve all the requested items. The segment also covers the handling of request errors and demonstrates how to request data by ID.
API Handlers for POSTMaximiliano demonstrates the process of creating a handler for handling API POST requests. The segment covers the handling of POST errors and includes a practical demonstration of a successful POST request.
Frameworks & External LibrariesMaximiliano discusses the benefits of using frameworks and external libraries to simplify the process of building applications in Go. The segment includes the implementation of the Gin web framework as an example to demonstrate how frameworks or external libraries can be utilized in Go development.
Compiling & PackagingMaximiliano covers the process of compiling a Go project, including the flexibility to compile for various platforms and operating systems. Additionally, in order to embed an application's assets, a package needs to be created, as Go produces binary files through compilation.