Skip to content

Commit

Permalink
Merge pull request #60 from fabianoflorentino/development
Browse files Browse the repository at this point in the history
Development to Main
  • Loading branch information
fabianoflorentino authored Dec 15, 2024
2 parents e4675c3 + 835224c commit b774b70
Show file tree
Hide file tree
Showing 18 changed files with 330 additions and 80 deletions.
19 changes: 15 additions & 4 deletions internal/funcoes/resolution_challange.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
// Package funcoes provides utility functions for performing various operations
// such as summing numbers with specific conditions. This package includes
// functions that demonstrate the use of higher-order functions and variadic
// parameters in Go.
package funcoes

import (
"fmt"
)

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

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

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

Expand All @@ -28,9 +38,10 @@ func soma(numeros ...int) int {
return somaNum
}

// somaImpares recebe uma função e um slice de inteiros e retorna a soma dos números pares.
// A função passada recebe um número variatico de inteiros e retorna um inteiro.
// 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.
// somaImapres takes a function `f` and a variadic number of integers `numeros`.
// It sums up the results of applying `f` to each odd number in `numeros`.
// The function `f` should accept a variadic number of integers and return an integer.
// The function returns the total sum of the results.
func somaImapres(f func(...int) int, numeros ...int) int {
soma := 0

Expand Down
29 changes: 28 additions & 1 deletion internal/funcoes/topics.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
// Package funcoes provides various examples and explanations of functions in Go.
// It covers topics such as function syntax, slices, defer, methods, interfaces,
// anonymous functions, function expressions, returning functions, callbacks,
// closures, and recursion. This package is part of the "aprendago" project,
// which aims to teach Go programming concepts.
package funcoes

import (
Expand All @@ -6,8 +11,15 @@ import (
"github.com/fabianoflorentino/aprendago/pkg/format"
)

const rootDir = "internal/funcoes"
// rootDir represents the relative path to the internal functions directory
// within the project. It is used to reference the location of function-related
// files and resources.
const (
rootDir = "internal/funcoes"
)

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

Expand All @@ -24,6 +36,12 @@ func Funcoes() {
executeSection("Recursividade")
}

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

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

// executeSection formats and processes a given section of the project.
// It takes a section name as a string and uses the FormatSection function
// from the format package to apply formatting to the specified section
// within the root directory.
func executeSection(section string) {
format.FormatSection(rootDir, section)
}
24 changes: 23 additions & 1 deletion internal/fundamentos_da_programacao/topics.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Package fundamentos_da_programacao provides fundamental concepts of programming in Go.
// It includes various sections that cover topics such as boolean types, how computers work,
// numeric types, overflow, string types, numeric systems, constants, iota, and bit shifting.
// The package offers functions to display these topics, generate menu options, and provide help descriptions.
package fundamentos_da_programacao

import (
Expand All @@ -6,8 +10,16 @@ import (
"github.com/fabianoflorentino/aprendago/pkg/format"
)

const rootDir = "internal/fundamentos_da_programacao"
// rootDir represents the relative path to the directory containing
// foundational programming topics within the project structure.
const (
rootDir = "internal/fundamentos_da_programacao"
)

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

Expand All @@ -22,6 +34,10 @@ func FundamentosDaProgramacao() {
executeSection("Deslocamento de bits")
}

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

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

// executeSection formats and processes a given section of the documentation.
// It takes a section name as a string and uses the FormatSection function
// from the format package to apply the necessary formatting to the section
// located in the root directory.
func executeSection(section string) {
format.FormatSection(rootDir, section)
}
9 changes: 9 additions & 0 deletions internal/menu/capitulo_options.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Package menu provides functionality to display and handle menu options for different chapters of a Go programming course.
// It includes functions to generate menu options and display help information for each chapter.
package menu

import (
Expand Down Expand Up @@ -29,6 +31,8 @@ import (
"github.com/fabianoflorentino/aprendago/pkg/format"
)

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

// HelpMeCapituloOptions prints a list of course chapters and their descriptions.
// Each chapter is represented by a flag and a description, which are printed
// in a formatted manner to the console. This function is useful for providing
// an overview of the course content and helping users navigate through different
// topics and exercises.
func HelpMeCapituloOptions() {
hlp := []format.HelpMe{
{Flag: "--cap=1 --topics", Description: "Visão Geral do Curso"},
Expand Down
10 changes: 10 additions & 0 deletions internal/menu/capitulo_outline.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Package menu provides functionality to display and handle the menu options
// for different chapters of the "aprendago" course. It includes functions to
// generate menu options and display help information for each chapter.
package menu

import (
Expand Down Expand Up @@ -28,6 +31,10 @@ import (
"github.com/fabianoflorentino/aprendago/pkg/format"
)

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

// HelpMeCapituloOutline prints the outline of the course chapters.
// Each chapter is represented by a flag and a description, which are stored in a slice of HelpMe structs.
// The function then prints the course outline using the PrintHelpMe function from the format package.
func HelpMeCapituloOutline() {
hlp := []format.HelpMe{
{Flag: "--cap=1 --overview", Description: "Visão Geral do Curso"},
Expand Down
12 changes: 10 additions & 2 deletions internal/menu/helpme.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Package menu provides functionality to display help and outline information
// for the "aprendago" application. It includes a function to show all available
// options and detailed help for each chapter of the course.
package menu

import (
Expand Down Expand Up @@ -28,6 +31,8 @@ import (
"github.com/fabianoflorentino/aprendago/internal/visao_geral_do_curso"
)

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

// ShowHelpMe exibe a lista de todas as opções disponíveis.
// Esta função é chamada quando o usuário passa a opção --help.
// HelpMe provides a comprehensive guide through various chapters and exercises
// of the Go programming course. It prints the header and sequentially calls
// helper functions for each chapter and exercise level, offering an overview
// and detailed explanations of variables, control flow, data grouping, structs,
// functions, pointers, concurrency, error handling, and more.
func HelpMe() {
fmt.Printf("%s\n", HEADER)
HelpMeCapituloOptions()
Expand Down
20 changes: 19 additions & 1 deletion internal/ponteiros/topics.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Package ponteiros provides functions and utilities to understand and work with pointers in Go.
// It includes sections on what pointers are, when to use them, and provides a menu and help options
// for navigating through the different topics related to pointers.
package ponteiros

import (
Expand All @@ -6,22 +9,34 @@ import (
"github.com/fabianoflorentino/aprendago/pkg/format"
)

const rootDir = "internal/ponteiros"
// rootDir represents the relative path to the directory where the pointer-related topics are stored within the project.
const (
rootDir = "internal/ponteiros"
)

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

executeSection("O que são ponteiros?")
executeSection("Quando usar ponteiros")
}

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

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

// executeSection formats and processes a specific section of the documentation.
// It takes a section name as a string parameter and uses the FormatSection function
// from the format package to apply the formatting to the section located in the rootDir.
func executeSection(section string) {
format.FormatSection(rootDir, section)
}
28 changes: 27 additions & 1 deletion internal/seu_ambiente_de_desenvolvimento/topics.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
// Package seu_ambiente_de_desenvolvimento provides functionalities to display and manage
// information related to the development environment setup. It includes sections on
// terminal usage, Go workspace and environment variables, IDEs, Go commands, GitHub
// repositories, cross-compilation, and packages. The package offers functions to display
// these sections, generate menu options, and provide help descriptions for each section.
package seu_ambiente_de_desenvolvimento

import (
Expand All @@ -6,8 +11,15 @@ import (
"github.com/fabianoflorentino/aprendago/pkg/format"
)

var rootDir = "internal/seu_ambiente_de_desenvolvimento"
// rootDir represents the root directory path for the development environment configuration files.
const (
rootDir = "internal/seu_ambiente_de_desenvolvimento"
)

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

Expand All @@ -21,6 +33,12 @@ func SeuAmbienteDeDesenvolvimento() {
executeSection("Pacotes")
}

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

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

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

0 comments on commit b774b70

Please sign in to comment.