This repository has been archived on 2026-03-18. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
lotus-package-manager/Tools/RegistryList.go
2021-10-31 01:03:13 +02:00

48 lines
No EOL
781 B
Go

package Tools
import (
"bufio"
"fmt"
"os"
)
type RegistryEntries struct{
entries map[string]string
}
var(
Registry RegistryEntries
)
func CheckIfRegistryFileExists() bool{
_, dirErr := os.Stat("data")
_, fileErr := os.Stat("data/registry.list")
if dirErr != nil || fileErr != nil {
return false
}
return true
}
func parseRegistryList() map[string]string{
file, err := os.Open("data/registry.list")
if err != nil {
ErrorLogger.Fatal(err)
}
lines := make(map[string]string)
scanner := bufio.NewScanner(file)
for scanner.Scan() {
if scanner.Text()[0] != '#'{
//TODO - Implement splitter
}
}
return lines
}
func LoadRegistryList() {
if CheckIfRegistryFileExists() {
Registry.entries = parseRegistryList()
fmt.Printf(Registry.entries["0"])
}
}