Skip to content

Commit 2de9a33

Browse files
committed
sáb 07 out 2023 02:19:15 -04 Vilmar Catafesta ([email protected])
1 parent de3c033 commit 2de9a33

File tree

2 files changed

+9
-14
lines changed

2 files changed

+9
-14
lines changed

usr/bin/big-pacman-to-json

0 Bytes
Binary file not shown.

usr/src/bigcontrolcenter-base/go/big-pacman-to-json.go

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -90,20 +90,20 @@ func ProcessOutput(input, xcmd string) {
9090
// Variáveis para manter as informações do pacote
9191
var packages []PackageInfo
9292
var currentPackage PackageInfo
93-
isDescription := false
94-
isName := false
93+
IsDescription := false
94+
IsName := false
9595

9696
// Divide o texto de entrada em linhas
9797
lines := strings.Split(input, "\n")
9898

9999
// Processa cada linha da entrada
100100
for _, line := range lines {
101101
// Verifica se a linha começa com 2 espaços iniciais (indica descrição)
102-
if strings.HasPrefix(line, " ") {
102+
if strings.HasPrefix(line, " ") && IsName == true {
103103
line = strings.TrimSpace(line)
104104
currentPackage.Description += line
105-
isDescription = true
106-
} else {
105+
IsDescription = true
106+
} else if IsName == false {
107107
// Divide a linha em campos e verifica se há pelo menos 2 campos (nome e versão)
108108
fields := strings.Fields(line)
109109
if len(fields) >= 1 {
@@ -134,20 +134,15 @@ func ProcessOutput(input, xcmd string) {
134134
currentPackage.Status = fields[2]
135135
}
136136
}
137-
isName = true
137+
IsName = true
138138
}
139139
}
140140
// Se a linha não começar com 2 espaços, isso indica o início de um novo pacote
141-
if isDescription == true && isName == true {
141+
if IsDescription == true && IsName == true {
142142
packages = append(packages, currentPackage)
143143
currentPackage = PackageInfo{}
144-
isDescription = false
145-
isName = false
146-
} else if isName == true {
147-
packages = append(packages, currentPackage)
148-
currentPackage = PackageInfo{}
149-
isDescription = false
150-
isName = false
144+
IsDescription = false
145+
IsName = false
151146
}
152147
}
153148

0 commit comments

Comments
 (0)