Skip to content

Commit b774b70

Browse files
Merge pull request #60 from fabianoflorentino/development
Development to Main
2 parents e4675c3 + 835224c commit b774b70

File tree

18 files changed

+330
-80
lines changed

18 files changed

+330
-80
lines changed

internal/funcoes/resolution_challange.go

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
1+
// Package funcoes provides utility functions for performing various operations
2+
// such as summing numbers with specific conditions. This package includes
3+
// functions that demonstrate the use of higher-order functions and variadic
4+
// parameters in Go.
15
package funcoes
26

37
import (
48
"fmt"
59
)
610

11+
// ResolucaoDesafioCallback calculates the sum of odd numbers from a given slice of integers
12+
// using the somaImpares function and prints the result along with an explanation.
13+
// The somaImpares function takes a function and a variadic number of integers, and returns
14+
// the sum of the odd numbers. The provided function sums the numbers if they are odd.
715
func ResolucaoDesafioCallback() {
816
result := somaImapres(soma, []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}...)
917

@@ -17,7 +25,9 @@ Os números recebidos pela função são variaticos e serão passados para a fun
1725
fmt.Println(explicacao)
1826
}
1927

20-
// soma recebe um número variatico de inteiros e retorna a soma de todos os números.
28+
// soma takes a variable number of integer arguments and returns their sum.
29+
// It iterates over the provided integers, adding each one to a cumulative total,
30+
// which is then returned as the result.
2131
func soma(numeros ...int) int {
2232
somaNum := 0
2333

@@ -28,9 +38,10 @@ func soma(numeros ...int) int {
2838
return somaNum
2939
}
3040

31-
// somaImpares recebe uma função e um slice de inteiros e retorna a soma dos números pares.
32-
// A função passada recebe um número variatico de inteiros e retorna um inteiro.
33-
// Os números recebidos pela função são variaticos e serão passados para a função que soma os números somente se forem ímpares.
41+
// somaImapres takes a function `f` and a variadic number of integers `numeros`.
42+
// It sums up the results of applying `f` to each odd number in `numeros`.
43+
// The function `f` should accept a variadic number of integers and return an integer.
44+
// The function returns the total sum of the results.
3445
func somaImapres(f func(...int) int, numeros ...int) int {
3546
soma := 0
3647

internal/funcoes/topics.go

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
// Package funcoes provides various examples and explanations of functions in Go.
2+
// It covers topics such as function syntax, slices, defer, methods, interfaces,
3+
// anonymous functions, function expressions, returning functions, callbacks,
4+
// closures, and recursion. This package is part of the "aprendago" project,
5+
// which aims to teach Go programming concepts.
16
package funcoes
27

38
import (
@@ -6,8 +11,15 @@ import (
611
"github.com/fabianoflorentino/aprendago/pkg/format"
712
)
813

9-
const rootDir = "internal/funcoes"
14+
// rootDir represents the relative path to the internal functions directory
15+
// within the project. It is used to reference the location of function-related
16+
// files and resources.
17+
const (
18+
rootDir = "internal/funcoes"
19+
)
1020

21+
// Funcoes prints the chapter title and executes a series of sections related to functions in Go.
22+
// Each section is executed by calling the executeSection function with the section name as an argument.
1123
func Funcoes() {
1224
fmt.Printf("\n\nCapítulo 12: Funções\n")
1325

@@ -24,6 +36,12 @@ func Funcoes() {
2436
executeSection("Recursividade")
2537
}
2638

39+
// MenuFuncoes returns a slice of format.MenuOptions, each representing a menu option
40+
// for different sections related to Go functions. Each menu option includes an
41+
// option string and an associated function to execute the corresponding section.
42+
// The sections covered include syntax, enumerating slices, defer, methods, interfaces
43+
// and polymorphism, anonymous functions, functions as expressions, returning functions,
44+
// callbacks, closure, and recursion.
2745
func MenuFuncoes([]string) []format.MenuOptions {
2846
return []format.MenuOptions{
2947
{Options: "--sintaxe", ExecFunc: func() { executeSection("Síntaxe") }},
@@ -41,6 +59,11 @@ func MenuFuncoes([]string) []format.MenuOptions {
4159
}
4260
}
4361

62+
// HelpMeFuncoes provides a list of help topics related to functions in Go.
63+
// Each topic includes a flag and a description explaining various concepts
64+
// such as function syntax, iterating over slices, defer statement, methods,
65+
// interfaces and polymorphism, anonymous functions, function expressions,
66+
// returning functions, callbacks, closures, and recursion.
4467
func HelpMeFuncoes() {
4568
hlp := []format.HelpMe{
4669
{Flag: "--sintaxe", Description: "Sintaxe de declaração de função", Width: 0},
@@ -61,6 +84,10 @@ func HelpMeFuncoes() {
6184
format.PrintHelpMe(hlp)
6285
}
6386

87+
// executeSection formats and processes a given section of the project.
88+
// It takes a section name as a string and uses the FormatSection function
89+
// from the format package to apply formatting to the specified section
90+
// within the root directory.
6491
func executeSection(section string) {
6592
format.FormatSection(rootDir, section)
6693
}

internal/fundamentos_da_programacao/topics.go

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// Package fundamentos_da_programacao provides fundamental concepts of programming in Go.
2+
// It includes various sections that cover topics such as boolean types, how computers work,
3+
// numeric types, overflow, string types, numeric systems, constants, iota, and bit shifting.
4+
// The package offers functions to display these topics, generate menu options, and provide help descriptions.
15
package fundamentos_da_programacao
26

37
import (
@@ -6,8 +10,16 @@ import (
610
"github.com/fabianoflorentino/aprendago/pkg/format"
711
)
812

9-
const rootDir = "internal/fundamentos_da_programacao"
13+
// rootDir represents the relative path to the directory containing
14+
// foundational programming topics within the project structure.
15+
const (
16+
rootDir = "internal/fundamentos_da_programacao"
17+
)
1018

19+
// FundamentosDaProgramacao prints the title "Fundamentos da Programação" and
20+
// executes a series of sections related to fundamental programming concepts.
21+
// Each section is executed by calling the executeSection function with a
22+
// specific topic name as an argument.
1123
func FundamentosDaProgramacao() {
1224
fmt.Print("\n\n04 - Fundamentos da Programação\n")
1325

@@ -22,6 +34,10 @@ func FundamentosDaProgramacao() {
2234
executeSection("Deslocamento de bits")
2335
}
2436

37+
// MenuFundamentosDaProgramcao returns a slice of format.MenuOptions, each representing
38+
// a different topic in the "Fundamentos da Programação" (Programming Fundamentals) section.
39+
// Each menu option has an associated execution function that calls executeSection with
40+
// the corresponding topic name.
2541
func MenuFundamentosDaProgramcao([]string) []format.MenuOptions {
2642
return []format.MenuOptions{
2743
{Options: "--tipo-booleano", ExecFunc: func() { executeSection("Tipo booleano") }},
@@ -36,6 +52,8 @@ func MenuFundamentosDaProgramcao([]string) []format.MenuOptions {
3652
}
3753
}
3854

55+
// HelpMeFundamentosDaProgramacao provides a list of topics related to the fundamentals of programming in Go.
56+
// Each topic is represented by a flag and a description, which explains the concept in detail.
3957
func HelpMeFundamentosDaProgramacao() {
4058
hlp := []format.HelpMe{
4159
{Flag: "--tipo-booleano", Description: "Explora o tipo de dados booleano em Go.", Width: 0},
@@ -53,6 +71,10 @@ func HelpMeFundamentosDaProgramacao() {
5371
format.PrintHelpMe(hlp)
5472
}
5573

74+
// executeSection formats and processes a given section of the documentation.
75+
// It takes a section name as a string and uses the FormatSection function
76+
// from the format package to apply the necessary formatting to the section
77+
// located in the root directory.
5678
func executeSection(section string) {
5779
format.FormatSection(rootDir, section)
5880
}

internal/menu/capitulo_options.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Package menu provides functionality to display and handle menu options for different chapters of a Go programming course.
2+
// It includes functions to generate menu options and display help information for each chapter.
13
package menu
24

35
import (
@@ -29,6 +31,8 @@ import (
2931
"github.com/fabianoflorentino/aprendago/pkg/format"
3032
)
3133

34+
// MenuCapituloOptions returns a slice of format.MenuOptions, each representing a chapter option with associated topics and execution functions.
35+
// The options are structured with a specific format "--cap=<chapter_number> --topics" and each option has an ExecFunc that calls a corresponding help function.
3236
func MenuCapituloOptions([]string) []format.MenuOptions {
3337
return []format.MenuOptions{
3438
{Options: "--cap=1 --topics", ExecFunc: func() { visao_geral_do_curso.HelpMeVisaoGeralDoCurso() }},
@@ -57,6 +61,11 @@ func MenuCapituloOptions([]string) []format.MenuOptions {
5761
}
5862
}
5963

64+
// HelpMeCapituloOptions prints a list of course chapters and their descriptions.
65+
// Each chapter is represented by a flag and a description, which are printed
66+
// in a formatted manner to the console. This function is useful for providing
67+
// an overview of the course content and helping users navigate through different
68+
// topics and exercises.
6069
func HelpMeCapituloOptions() {
6170
hlp := []format.HelpMe{
6271
{Flag: "--cap=1 --topics", Description: "Visão Geral do Curso"},

internal/menu/capitulo_outline.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// Package menu provides functionality to display and handle the menu options
2+
// for different chapters of the "aprendago" course. It includes functions to
3+
// generate menu options and display help information for each chapter.
14
package menu
25

36
import (
@@ -28,6 +31,10 @@ import (
2831
"github.com/fabianoflorentino/aprendago/pkg/format"
2932
)
3033

34+
// MenuCapituloOutline returns a slice of format.MenuOptions, each representing
35+
// a chapter outline with an associated command-line option and execution function.
36+
// The options are structured as "--cap=<chapter_number> --overview" and the
37+
// corresponding ExecFunc executes a specific function related to that chapter.
3138
func MenuCapituloOutline([]string) []format.MenuOptions {
3239
return []format.MenuOptions{
3340
{Options: "--cap=1 --overview", ExecFunc: func() { visao_geral_do_curso.VisaoGeralDoCurso() }},
@@ -56,6 +63,9 @@ func MenuCapituloOutline([]string) []format.MenuOptions {
5663
}
5764
}
5865

66+
// HelpMeCapituloOutline prints the outline of the course chapters.
67+
// Each chapter is represented by a flag and a description, which are stored in a slice of HelpMe structs.
68+
// The function then prints the course outline using the PrintHelpMe function from the format package.
5969
func HelpMeCapituloOutline() {
6070
hlp := []format.HelpMe{
6171
{Flag: "--cap=1 --overview", Description: "Visão Geral do Curso"},

internal/menu/helpme.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// Package menu provides functionality to display help and outline information
2+
// for the "aprendago" application. It includes a function to show all available
3+
// options and detailed help for each chapter of the course.
14
package menu
25

36
import (
@@ -28,6 +31,8 @@ import (
2831
"github.com/fabianoflorentino/aprendago/internal/visao_geral_do_curso"
2932
)
3033

34+
// HEADER is a constant string that provides usage instructions for running the Go program.
35+
// It includes an example command and descriptions of available options such as --outline, --help, and --caps.
3136
const HEADER = `
3237
Uso: go run cmd/aprendago/main.go [opção]
3338
@@ -41,8 +46,11 @@ Ajuda:
4146
--caps Exibe a lista de capítulos disponíveis.
4247
`
4348

44-
// ShowHelpMe exibe a lista de todas as opções disponíveis.
45-
// Esta função é chamada quando o usuário passa a opção --help.
49+
// HelpMe provides a comprehensive guide through various chapters and exercises
50+
// of the Go programming course. It prints the header and sequentially calls
51+
// helper functions for each chapter and exercise level, offering an overview
52+
// and detailed explanations of variables, control flow, data grouping, structs,
53+
// functions, pointers, concurrency, error handling, and more.
4654
func HelpMe() {
4755
fmt.Printf("%s\n", HEADER)
4856
HelpMeCapituloOptions()

internal/ponteiros/topics.go

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// Package ponteiros provides functions and utilities to understand and work with pointers in Go.
2+
// It includes sections on what pointers are, when to use them, and provides a menu and help options
3+
// for navigating through the different topics related to pointers.
14
package ponteiros
25

36
import (
@@ -6,22 +9,34 @@ import (
69
"github.com/fabianoflorentino/aprendago/pkg/format"
710
)
811

9-
const rootDir = "internal/ponteiros"
12+
// rootDir represents the relative path to the directory where the pointer-related topics are stored within the project.
13+
const (
14+
rootDir = "internal/ponteiros"
15+
)
1016

17+
// Ponteiros prints the chapter title and executes sections related to pointers.
18+
// It covers topics such as what pointers are and when to use them.
1119
func Ponteiros() {
1220
fmt.Printf("\n\nCapítulo 14: Ponteiros\n")
1321

1422
executeSection("O que são ponteiros?")
1523
executeSection("Quando usar ponteiros")
1624
}
1725

26+
// MenuPonteiros returns a slice of MenuOptions for the "ponteiros" topic.
27+
// Each MenuOption contains an option string and an associated execution function.
28+
// The options provided are:
29+
// --o-que-sao-ponteiros: Executes the section explaining what pointers are.
30+
// --quando-usar-ponteiros: Executes the section explaining when to use pointers.
1831
func MenuPonteiros([]string) []format.MenuOptions {
1932
return []format.MenuOptions{
2033
{Options: "--o-que-sao-ponteiros", ExecFunc: func() { executeSection("O que são ponteiros?") }},
2134
{Options: "--quando-usar-ponteiros", ExecFunc: func() { executeSection("Quando usar ponteiros") }},
2235
}
2336
}
2437

38+
// HelpMePonteiros prints a help message for the "Ponteiros" (Pointers) chapter.
39+
// It provides descriptions of what pointers are in Go and when to use them.
2540
func HelpMePonteiros() {
2641
hlp := []format.HelpMe{
2742
{Flag: "--o-que-sao-ponteiros", Description: "Descreve o que são ponteiros em Go", Width: 0},
@@ -32,6 +47,9 @@ func HelpMePonteiros() {
3247
format.PrintHelpMe(hlp)
3348
}
3449

50+
// executeSection formats and processes a specific section of the documentation.
51+
// It takes a section name as a string parameter and uses the FormatSection function
52+
// from the format package to apply the formatting to the section located in the rootDir.
3553
func executeSection(section string) {
3654
format.FormatSection(rootDir, section)
3755
}

internal/seu_ambiente_de_desenvolvimento/topics.go

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
// Package seu_ambiente_de_desenvolvimento provides functionalities to display and manage
2+
// information related to the development environment setup. It includes sections on
3+
// terminal usage, Go workspace and environment variables, IDEs, Go commands, GitHub
4+
// repositories, cross-compilation, and packages. The package offers functions to display
5+
// these sections, generate menu options, and provide help descriptions for each section.
16
package seu_ambiente_de_desenvolvimento
27

38
import (
@@ -6,8 +11,15 @@ import (
611
"github.com/fabianoflorentino/aprendago/pkg/format"
712
)
813

9-
var rootDir = "internal/seu_ambiente_de_desenvolvimento"
14+
// rootDir represents the root directory path for the development environment configuration files.
15+
const (
16+
rootDir = "internal/seu_ambiente_de_desenvolvimento"
17+
)
1018

19+
// SeuAmbienteDeDesenvolvimento prints the title of Chapter 19 and executes a series of sections
20+
// related to setting up and understanding your development environment in Go. The sections include
21+
// topics such as using the terminal, Go workspace and environment variables, IDEs, Go commands,
22+
// GitHub repositories, exploring GitHub, cross-compilation, and packages.
1123
func SeuAmbienteDeDesenvolvimento() {
1224
fmt.Print("\n\nCapítulo 19: Seu Ambiente de Desenvolvimento\n")
1325

@@ -21,6 +33,12 @@ func SeuAmbienteDeDesenvolvimento() {
2133
executeSection("Pacotes")
2234
}
2335

36+
// MenuSeuAmbienteDeDesenvolvimento returns a slice of format.MenuOptions,
37+
// each representing a different development environment topic with an associated
38+
// execution function. The options include topics such as terminal usage, Go workspace
39+
// and environment variables, IDEs, Go commands, GitHub repositories, exploring GitHub,
40+
// cross-compilation, and packages. Each option is linked to a function that executes
41+
// the corresponding section.
2442
func MenuSeuAmbienteDeDesenvolvimento([]string) []format.MenuOptions {
2543
return []format.MenuOptions{
2644
{Options: "--o-terminal", ExecFunc: func() { executeSection("O terminal") }},
@@ -34,6 +52,10 @@ func MenuSeuAmbienteDeDesenvolvimento([]string) []format.MenuOptions {
3452
}
3553
}
3654

55+
// HelpMeSeuAmbienteDeDesenvolvimento provides a list of help topics related to the development environment.
56+
// It includes information about the terminal, Go workspace environment variables, IDEs, Go commands,
57+
// GitHub repositories, exploring GitHub, cross-compilation, and packages.
58+
// The function prints the chapter title and then displays the help topics using the format.PrintHelpMe function.
3759
func HelpMeSeuAmbienteDeDesenvolvimento() {
3860
hlp := []format.HelpMe{
3961
{Flag: "--o-terminal", Description: "Exibe informações sobre o terminal."},
@@ -50,6 +72,10 @@ func HelpMeSeuAmbienteDeDesenvolvimento() {
5072
format.PrintHelpMe(hlp)
5173
}
5274

75+
// executeSection formats and processes a given section of the project.
76+
// It takes a section name as a string parameter and uses the FormatSection
77+
// function from the format package to format the specified section within
78+
// the root directory.
5379
func executeSection(section string) {
5480
format.FormatSection(rootDir, section)
5581
}

0 commit comments

Comments
 (0)