fix: read multiple depends key from DATA file
This commit is contained in:
28
lib/util.go
28
lib/util.go
@ -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
|
||||
|
Reference in New Issue
Block a user