Skip to content

Commit f066d29

Browse files
Merge pull request #88 from fabianoflorentino/development
Development to Main
2 parents 30c30ce + 62be05f commit f066d29

File tree

17 files changed

+393
-136
lines changed

17 files changed

+393
-136
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,10 @@ Outline do Curso por Capítulo
200200
│   │   ├── examples.go
201201
│   │   ├── help.go
202202
│   │   ├── menu.go
203+
│   │   ├── menu_test.go
203204
│   │   ├── overview.yml
204-
│   │   └── topics.go
205+
│   │   ├── topics.go
206+
│   │   └── topics_test.go
205207
│   ├── canais
206208
│   │   ├── examples.go
207209
│   │   ├── overview.yml
@@ -338,7 +340,7 @@ Outline do Curso por Capítulo
338340
│   └── trim.go
339341
└── tree.log
340342

341-
44 directories, 121 files
343+
44 directories, 123 files
342344
```
343345

344346
## Licença

internal/agrupamento_de_dados/constants.go

Lines changed: 45 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,50 @@ const (
66
rootDir = "internal/agrupamento_de_dados"
77
)
88

9-
// Array represents a fixed-size sequence of elements of the same type.
10-
// Arrays in Go have a fixed length, and their size is part of their type.
11-
// They are useful when you know the exact number of elements you need to store.
9+
// The following constants define the names of various topics related to data grouping in Go.
10+
// Each constant corresponds to a specific topic and provides a human-readable name for it.
1211
const (
13-
Array string = "Array"
14-
SliceLiteralComposta string = "Slice: literal composta"
15-
SliceForRange string = "Slice: for range"
16-
SliceFatiandoOuDeletando string = "Slice: fatiando ou deletando de uma fatia"
17-
SliceAnexando string = "Slice: anexando a uma slice"
18-
SliceMake string = "Slice: make"
19-
SliceMultiDimensional string = "Slice: multi dimensional"
20-
SliceSurpresaArraySubjacente string = "Slice: a surpresa do array subjacente"
21-
MapsIntroducao string = "Maps: introdução"
22-
MapsRangeEDeletando string = "Maps: range e deletando"
12+
array string = "Array"
13+
sliceLiteralComposta string = "Slice: literal composta"
14+
sliceForRange string = "Slice: for range"
15+
sliceFatiandoOuDeletando string = "Slice: fatiando ou deletando de uma fatia"
16+
sliceAnexando string = "Slice: anexando a uma slice"
17+
sliceMake string = "Slice: make"
18+
sliceMultiDimensional string = "Slice: multi dimensional"
19+
sliceSurpresaArraySubjacente string = "Slice: a surpresa do array subjacente"
20+
mapsIntroducao string = "Maps: introdução"
21+
mapsRangeEDeletando string = "Maps: range e deletando"
22+
)
23+
24+
// The following constants define command-line flags for various topics related to data grouping in Go.
25+
// Each flag corresponds to a specific topic and is used to trigger functionality or operations
26+
// associated with that topic in the application.
27+
const (
28+
flagArray string = "--array"
29+
flagSliceLiteralComposta string = "--slice-literal-composta"
30+
flagSliceForRange string = "--slice-for-range"
31+
flagSliceFatiandoOuDeletando string = "--slice-fatiando-ou-deletando-de-uma-fatia"
32+
flagSliceFatiandoOuDeletandoRes string = "--slice-fatiando-ou-deletando-de-uma-fatia --resolucao"
33+
flagSliceAnexando string = "--slice-anexando-a-uma-slice"
34+
flagSliceMake string = "--slice-make"
35+
flagSliceMultiDimensional string = "--slice-multi-dimensional"
36+
flagSliceSurpresaArraySubjacente string = "--slice-a-surpresa-do-array-subjacente"
37+
flagMapsIntroducao string = "--maps-introducao"
38+
flagMapsRangeEDeletando string = "--maps-range-e-deletando"
39+
)
40+
41+
// The following constants provide descriptions for various topics related to data grouping in Go.
42+
// Each constant corresponds to a specific topic and gives a brief explanation of its purpose or content.
43+
const (
44+
descArray string = "Apresenta o tópico Array."
45+
descSliceLiteralComposta string = "Apresenta o tópico Slice Literal Composta."
46+
descSliceForRange string = "Apresenta o tópico Slice: for range."
47+
descSliceFatiandoOuDeletando string = "Apresenta o tópico Slice: fatiando ou deletando de uma fatia."
48+
descSliceFatiandoOuDeletandoRes string = "Apresenta a resolução do tópico Slice: fatiando ou deletando de uma fatia."
49+
descSliceAnexando string = "Apresenta o tópico Slice: anexando a uma slice."
50+
descSliceMake string = "Apresenta o tópico Slice: Make."
51+
descSliceMultiDimensional string = "Apresenta o tópico Slice: Multi Dimensional."
52+
descSliceSurpresaArraySubjacente string = "Apresenta o tópico Slice: a surpresa do array subjacente."
53+
descMapsIntroducao string = "Apresenta o tópico Maps: introdução."
54+
descMapsRangeEDeletando string = "Apresenta o tópico Maps: Range e Deletando."
2355
)

internal/agrupamento_de_dados/help.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,20 @@ import (
1818
// the format.HelpMe structure to organize the flags and their corresponding descriptions,
1919
// and outputs the information using the format.PrintHelpMe function.
2020
func Help() {
21-
hlp := []format.HelpMe{
22-
{Flag: "--array", Description: "Apresenta o tópico Array."},
23-
{Flag: "--slice-literal-composta", Description: "Apresenta o tópico Slice Literal Composta."},
24-
{Flag: "--slice-for-range", Description: "Apresenta o tópico Slice: for range."},
25-
{Flag: "--slice-fatiando-ou-deletando-de-uma-fatia", Description: "Apresenta o tópico Slice: fatiando ou deletando de uma fatia."},
26-
{Flag: "--slice-fatiando-ou-deletando-de-uma-fatia --resolucao", Description: "Apresenta a resolução do tópico Slice: fatiando ou deletando de uma fatia."},
27-
{Flag: "--slice-anexando-a-uma-slice", Description: "Apresenta o tópico Slice: anexando a uma slice."},
28-
{Flag: "--slice-make", Description: "Apresenta o tópico Slice: Make."},
29-
{Flag: "--slice-multi-dimensional", Description: "Apresenta o tópico Slice: Multi Dimensional."},
30-
{Flag: "--slice-a-surpresa-do-array-subjacente", Description: "Apresenta o tópico Slice: a surpresa do array subjacente."},
31-
{Flag: "--maps-introducao", Description: "Apresenta o tópico Maps: introdução."},
32-
{Flag: "--maps-range-e-deletando", Description: "Apresenta o tópico Maps: Range e Deletando."},
21+
h := []format.HelpMe{
22+
{Flag: flagArray, Description: descArray},
23+
{Flag: flagSliceLiteralComposta, Description: descSliceLiteralComposta},
24+
{Flag: flagSliceForRange, Description: descSliceForRange},
25+
{Flag: flagSliceFatiandoOuDeletando, Description: descSliceFatiandoOuDeletando},
26+
{Flag: flagSliceFatiandoOuDeletandoRes, Description: descSliceFatiandoOuDeletandoRes},
27+
{Flag: flagSliceAnexando, Description: descSliceAnexando},
28+
{Flag: flagSliceMake, Description: descSliceMake},
29+
{Flag: flagSliceMultiDimensional, Description: descSliceMultiDimensional},
30+
{Flag: flagSliceSurpresaArraySubjacente, Description: descSliceSurpresaArraySubjacente},
31+
{Flag: flagMapsIntroducao, Description: descMapsIntroducao},
32+
{Flag: flagMapsRangeEDeletando, Description: descMapsRangeEDeletando},
3333
}
3434

35-
fmt.Println("\nCapítulo 8: Agrupamento de Dados")
36-
format.PrintHelpMe(hlp)
35+
fmt.Println("Capítulo 8: Agrupamento de Dados")
36+
format.PrintHelpMe(h)
3737
}

internal/agrupamento_de_dados/menu.go

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,29 @@ func Menu(menu []string) []format.MenuOptions {
2121
section, err := section.New(rootDir)
2222
if err != nil {
2323
logger.New("Error creating section: ", err.Error()).Register()
24-
return nil
2524
}
2625

2726
return []format.MenuOptions{
28-
{Options: "--array", ExecFunc: func() { section.Format("Array") }},
29-
{Options: "--slice-literal-composta", ExecFunc: func() { section.Format("Slice: literal composta") }},
30-
{Options: "--slice-for-range", ExecFunc: func() { section.Format("Slice: for range") }},
31-
{Options: "--slice-fatiando-ou-deletando-de-uma-fatia", ExecFunc: func() { section.Format("Slice: fatiando ou deletando de uma fatia") }},
32-
{Options: "--slice-anexando-a-uma-slice", ExecFunc: func() { section.Format("Slice: anexando a uma slice") }},
33-
{Options: "--slice-make", ExecFunc: func() { section.Format("Slice: make") }},
34-
{Options: "--slice-multi-dimensional", ExecFunc: func() { section.Format("Slice: multi dimensional") }},
35-
{Options: "--slice-a-surpresa-do-array-subjacente", ExecFunc: func() { section.Format("Slice: a surpresa do array subjacente") }},
36-
{Options: "--maps-introducao", ExecFunc: func() { section.Format("Maps: introdução") }},
37-
{Options: "--maps-range-e-deletando", ExecFunc: func() { section.Format("Maps: range e deletando") }},
27+
{Options: flagArray, ExecFunc: func() { sectionsAgrupamentoDeDados(array, section) }},
28+
{Options: flagSliceLiteralComposta, ExecFunc: func() { sectionsAgrupamentoDeDados(sliceLiteralComposta, section) }},
29+
{Options: flagSliceForRange, ExecFunc: func() { sectionsAgrupamentoDeDados(sliceForRange, section) }},
30+
{Options: flagSliceFatiandoOuDeletando, ExecFunc: func() { sectionsAgrupamentoDeDados(sliceFatiandoOuDeletando, section) }},
31+
{Options: flagSliceAnexando, ExecFunc: func() { sectionsAgrupamentoDeDados(sliceAnexando, section) }},
32+
{Options: flagSliceMake, ExecFunc: func() { sectionsAgrupamentoDeDados(sliceMake, section) }},
33+
{Options: flagSliceMultiDimensional, ExecFunc: func() { sectionsAgrupamentoDeDados(sliceMultiDimensional, section) }},
34+
{Options: flagSliceSurpresaArraySubjacente, ExecFunc: func() { sectionsAgrupamentoDeDados(sliceSurpresaArraySubjacente, section) }},
35+
{Options: flagMapsIntroducao, ExecFunc: func() { sectionsAgrupamentoDeDados(mapsIntroducao, section) }},
36+
{Options: flagMapsRangeEDeletando, ExecFunc: func() { sectionsAgrupamentoDeDados(mapsRangeEDeletando, section) }},
3837
}
3938
}
39+
40+
// sectionsAgrupamentoDeDados formats and processes sections of data under a given title.
41+
// It utilizes the SectionProvider interface to handle the formatting logic.
42+
//
43+
// Parameters:
44+
// - title: A string representing the title for the sections.
45+
// - sections: An implementation of the section.SectionProvider interface
46+
// that provides the functionality to format the sections.
47+
func sectionsAgrupamentoDeDados(title string, sections section.SectionProvider) {
48+
sections.Format(title)
49+
}

internal/agrupamento_de_dados/menu_test.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@ func TestMenu(t *testing.T) {
1616
// Create a slice of MenuOptions.
1717
menuOptions := Menu(
1818
[]string{
19-
"--array",
20-
"--slice-literal-composta",
21-
"--slice-for-range",
22-
"--slice-fatiando-ou-deletando-de-uma-fatia",
23-
"--slice-anexando-a-uma-slice",
24-
"--slice-make",
25-
"--slice-multi-dimensional",
26-
"--slice-a-surpresa-do-array-subjacente",
27-
"--maps-introducao",
28-
"--maps-range-e-deletando",
19+
flagArray,
20+
flagSliceLiteralComposta,
21+
flagSliceForRange,
22+
flagSliceFatiandoOuDeletando,
23+
flagSliceFatiandoOuDeletandoRes,
24+
flagSliceAnexando,
25+
flagSliceMake,
26+
flagSliceMultiDimensional,
27+
flagSliceSurpresaArraySubjacente,
28+
flagMapsIntroducao,
2929
})
3030

3131
// Check if the menuOptions slice has the expected length.

internal/agrupamento_de_dados/overview.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
description:
3-
name: "08 - Agrupamento de Dados"
3+
name: "Capítulo 8: Agrupamento de Dados"
44
sections:
55
- title: Array
66
text: |

internal/agrupamento_de_dados/topics.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,16 @@ func contentsAgrupamentoDeDados(rootDir string, contents topic.ContentsProvider)
3535
// the topics related to "agrupamento de dados" (data grouping) in Go.
3636
func listOfTopicsAgrupamentoDeDados() []string {
3737
list := []string{
38-
Array,
39-
SliceLiteralComposta,
40-
SliceForRange,
41-
SliceFatiandoOuDeletando,
42-
SliceAnexando,
43-
SliceMake,
44-
SliceMultiDimensional,
45-
SliceSurpresaArraySubjacente,
46-
MapsIntroducao,
47-
MapsRangeEDeletando,
38+
array,
39+
sliceLiteralComposta,
40+
sliceForRange,
41+
sliceFatiandoOuDeletando,
42+
sliceAnexando,
43+
sliceMake,
44+
sliceMultiDimensional,
45+
sliceSurpresaArraySubjacente,
46+
mapsIntroducao,
47+
mapsRangeEDeletando,
4848
}
4949

5050
return listOfTopics(list)

internal/agrupamento_de_dados/topics_test.go

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
// Package agrupamento_de_dados provides functionality for grouping and managing data topics.
2+
// It includes utilities for handling arrays, slices, maps, and other data structures,
3+
// as well as functions for organizing and retrieving topic-related content.
14
package agrupamento_de_dados
25

36
import (
47
"testing"
58
)
69

7-
// MockContentsProvider is a mock implementation of the topic.ContentsProvider interface.
810
type MockContentsProvider struct {
911
CalledWithRootDir string
1012
CalledWithTopics []string
@@ -43,16 +45,16 @@ func TestTopics(t *testing.T) {
4345

4446
func TestListOfTopicsAgrupamentoDeDados(t *testing.T) {
4547
expected := []string{
46-
Array,
47-
SliceLiteralComposta,
48-
SliceForRange,
49-
SliceFatiandoOuDeletando,
50-
SliceAnexando,
51-
SliceMake,
52-
SliceMultiDimensional,
53-
SliceSurpresaArraySubjacente,
54-
MapsIntroducao,
55-
MapsRangeEDeletando,
48+
array,
49+
sliceLiteralComposta,
50+
sliceForRange,
51+
sliceFatiandoOuDeletando,
52+
sliceAnexando,
53+
sliceMake,
54+
sliceMultiDimensional,
55+
sliceSurpresaArraySubjacente,
56+
mapsIntroducao,
57+
mapsRangeEDeletando,
5658
}
5759

5860
result := listOfTopicsAgrupamentoDeDados()

internal/aplicacoes/constants.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,33 @@ const (
1717
CustomizandoSort string = "Customizando sort"
1818
Bcrypt string = "bcrypt"
1919
)
20+
21+
const (
22+
flagDocumentacaoJSON string = "--documentacao-json"
23+
flagDocumentacaoJSONExampleJSONMarshal string = "--documentacao-json --example --json-marshal"
24+
flagDocumentacaoJSONExampleJSONUnmarshal string = "--documentacao-json --example --json-unmarshal"
25+
flagDocumentacaoJSONExampleJSONEncoder string = "--documentacao-json --example --json-encoder"
26+
flagJSONMarshal string = "--json-marshal"
27+
flagJSONUnmarshal string = "--json-unmarshal"
28+
flagInterfaceWriter string = "--interface-writer"
29+
flagPacoteSort string = "--pacote-sort"
30+
flagPacoteSortExample string = "--pacote-sort --example"
31+
flagCustomizandoSort string = "--customizando-sort"
32+
flagCustomizandoSortExample string = "--customizando-sort --example"
33+
flagBcrypt string = "--bcrypt"
34+
)
35+
36+
const (
37+
descDocumentacaoJSON string = "Descreve como documentar um pacote em Go"
38+
descDocumentacaoJSONExampleJSONMarshal string = "Exemplo de como ordenar um JSON"
39+
descDocumentacaoJSONExampleJSONUnmarshal string = "Exemplo de como desordenar um JSON"
40+
descDocumentacaoJSONExampleJSONEncoder string = "Exemplo de como usar o encoder JSON"
41+
descJSONMarshal string = "Descreve o pacote json.Marshal"
42+
descJSONUnmarshal string = "Descreve o pacote json.Unmarshal"
43+
descInterfaceWriter string = "Descreve o que é a interface Writer"
44+
descPacoteSort string = "Descreve o pacote sort"
45+
descPacoteSortExample string = "Exemplo de como usar o pacote sort"
46+
descCustomizandoSort string = "Descreve como customizar o pacote sort"
47+
descCustomizandoSortExample string = "Exemplo de como customizar o pacote sort"
48+
descBcrypt string = "Descreve o pacote bcrypt"
49+
)

internal/aplicacoes/help.go

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,21 @@ import (
1010
// It prints out a formatted help guide for each topic, including flags and descriptions.
1111
// The topics cover documentation, JSON handling, interfaces, sorting, and encryption with bcrypt.
1212
func Help() {
13-
hlp := []format.HelpMe{
14-
{Flag: "--documentacao-json", Description: "Descreve como documentar um pacote em Go", Width: 0},
15-
{Flag: "--documentacao-json --example --json-marshal", Description: "Exemplo de como ordenar um JSON", Width: 0},
16-
{Flag: "--documentacao-json --example --json-unmarshal", Description: "Exemplo de como desordenar um JSON", Width: 0},
17-
{Flag: "--documentacao-json --example --json-encoder", Description: "Exemplo de como usar o encoder JSON", Width: 0},
18-
{Flag: "--json-marshal", Description: "Descreve o pacote json.Marshal", Width: 0},
19-
{Flag: "--json-unmarshal", Description: "Descreve o pacote json.Unmarshal", Width: 0},
20-
{Flag: "--interface-writer", Description: "Descreve o que é a interface Writer", Width: 0},
21-
{Flag: "--pacote-sort", Description: "Descreve o pacote sort", Width: 0},
22-
{Flag: "--pacote-sort --example", Description: "Exemplo de como usar o pacote sort", Width: 0},
23-
{Flag: "--customizando-sort --example", Description: "Descreve como customizar o pacote sort", Width: 0},
24-
{Flag: "--bcrypt", Description: "Descreve o pacote bcrypt", Width: 0},
13+
h := []format.HelpMe{
14+
{Flag: flagDocumentacaoJSON, Description: descDocumentacaoJSON},
15+
{Flag: flagDocumentacaoJSONExampleJSONMarshal, Description: descDocumentacaoJSONExampleJSONMarshal},
16+
{Flag: flagDocumentacaoJSONExampleJSONUnmarshal, Description: descDocumentacaoJSONExampleJSONUnmarshal},
17+
{Flag: flagDocumentacaoJSONExampleJSONEncoder, Description: descDocumentacaoJSONExampleJSONEncoder},
18+
{Flag: flagJSONMarshal, Description: descJSONMarshal},
19+
{Flag: flagJSONUnmarshal, Description: descJSONUnmarshal},
20+
{Flag: flagInterfaceWriter, Description: descInterfaceWriter},
21+
{Flag: flagPacoteSort, Description: descPacoteSort},
22+
{Flag: flagPacoteSortExample, Description: descPacoteSortExample},
23+
{Flag: flagCustomizandoSort, Description: descCustomizandoSort},
24+
{Flag: flagCustomizandoSortExample, Description: descCustomizandoSortExample},
25+
{Flag: flagBcrypt, Description: descBcrypt},
2526
}
2627

2728
fmt.Printf("\nCapítulo 16: Aplicações\n")
28-
format.PrintHelpMe(hlp)
29+
format.PrintHelpMe(h)
2930
}

0 commit comments

Comments
 (0)