fix: read multiple depends key from DATA file

This commit is contained in:
ngn
2024-08-26 02:33:38 +03:00
parent 9c61c49b96
commit 6810f9b2ec
2 changed files with 39 additions and 11 deletions

View File

@ -2,6 +2,7 @@ package lib
import (
"archive/tar"
"bufio"
"compress/gzip"
"fmt"
"io"
@ -11,6 +12,33 @@ import (
"github.com/gofiber/fiber/v2"
)
// configparser can't get multiple keys, so heres a function to manually extract them
func GetMultiple(k string, r io.Reader) ([]string, error) {
var (
res []string
value string
scanner *bufio.Scanner
)
scanner = bufio.NewScanner(r)
for scanner.Scan() {
line := scanner.Text()
value = strings.TrimPrefix(line, fmt.Sprintf("%s = ", k))
value = strings.TrimPrefix(value, fmt.Sprintf("%s =", k))
value = strings.TrimPrefix(value, fmt.Sprintf("%s= ", k))
value = strings.TrimPrefix(value, fmt.Sprintf("%s=", k))
if line == value {
continue
}
res = append(res, value)
}
return res, nil
}
func GetFiles(r io.Reader) ([]string, error) {
var (
gzip_reader io.Reader