Modified RegistryList
This commit is contained in:
parent
5a48f755a2
commit
61effffff4
1 changed files with 13 additions and 11 deletions
|
|
@ -6,10 +6,14 @@ import (
|
||||||
"os"
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
type RegistryList struct {
|
type RegistryEntries struct{
|
||||||
Registries []string
|
entries map[string]string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var(
|
||||||
|
Registry RegistryEntries
|
||||||
|
)
|
||||||
|
|
||||||
func CheckIfRegistryFileExists() bool{
|
func CheckIfRegistryFileExists() bool{
|
||||||
_, dirErr := os.Stat("data")
|
_, dirErr := os.Stat("data")
|
||||||
_, fileErr := os.Stat("data/registry.list")
|
_, fileErr := os.Stat("data/registry.list")
|
||||||
|
|
@ -19,28 +23,26 @@ func CheckIfRegistryFileExists() bool{
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseRegistryList() []string{
|
func parseRegistryList() map[string]string{
|
||||||
file, err := os.Open("data/registry.list")
|
file, err := os.Open("data/registry.list")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ErrorLogger.Fatal(err)
|
ErrorLogger.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
lines := make([]string, 512)
|
lines := make(map[string]string)
|
||||||
scanner := bufio.NewScanner(file)
|
scanner := bufio.NewScanner(file)
|
||||||
|
|
||||||
i := 0
|
|
||||||
for scanner.Scan() {
|
for scanner.Scan() {
|
||||||
if scanner.Text()[0] != '#'{
|
if scanner.Text()[0] != '#'{
|
||||||
lines[i] = scanner.Text()
|
//TODO - Implement splitter
|
||||||
i++
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return lines
|
return lines
|
||||||
}
|
}
|
||||||
|
|
||||||
func LoadRegistryList(){
|
func LoadRegistryList() {
|
||||||
if CheckIfRegistryFileExists(){
|
if CheckIfRegistryFileExists() {
|
||||||
|
Registry.entries = parseRegistryList()
|
||||||
registries := parseRegistryList()
|
fmt.Printf(Registry.entries["0"])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in a new issue