Welcome to the learn-go repository! This project was originally created as course material to teach the Go programming language. I've decided to leave it public as a resource for anyone interested in learning Go.
The repository is structured into sequential folders, each covering a specific topic, from the very basics to more advanced concepts like building a RESTful API.
This repository is structured for simplicity. Almost every .go file inside the topic folders (00 to 14) is a self-contained example with its own main function.
To avoid the complexity of creating separate modules for each example, please follow these steps to run any file:
-
Choose an example you'd like to run from one of the folders (e.g.,
01-variaveis/01-declaracao-de-variaveis.go). -
Copy the entire content of that file.
-
Paste the content into the
main.gofile located in the root of this repository, completely replacing what's there. -
Open your terminal in the repository's root directory and execute the following command:
go run main.go
Please be aware that the code comments are written in a mix of Portuguese (pt-br) and English.
Before you start, make sure you have Go installed on your machine. If you don't, you can download and find installation instructions on the official website.
The repository is organized by topic in the following order:
00-introducao: Basic syntax, compilation, and execution.01-variaveis: Declaring variables and constants.02-saida-de-dados: Printing data to the console (Print,Println,Printf).03-tipos-de-dados: Go's fundamental data types (integers, floats, strings, booleans).04-arrays: Working with fixed-size arrays.05-slices: Using dynamic arrays (slices), including capacity, length, and manipulation.06-operadores: Arithmetic, assignment, comparison, logical, and binary operators.07-condicionais:if,else,else if, andswitchstatements.08-loops:forloops, includingbreakandcontinue.09-funcoes: Defining, calling, and returning values from functions.10-structs-and-maps: Working with custom data structures (structs) and key-value pairs (maps).11-modules: Creating and using Go modules.12-workspaces: Managing multiple modules with Go workspaces.13-relation-data-base: Connecting to and querying a relational database.14-restful-api: Building a simple RESTful API.
Happy coding! ✨