ctdo.de/yml.go

56 lines
928 B
Go

package main
import "strings"
func readDatabaseYML() database {
file := fileRead("./config/database.yml")
rows := [][]string{}
for _, row := range strings.Split(file, "\n") {
rows = append(rows, strings.Split(row, ": "))
}
output := new(database)
for i, row := range rows {
switch i {
case 0:
output.username = row[1]
case 1:
output.password = row[1]
case 2:
output.address = row[1]
case 3:
output.port = row[1]
case 4:
output.database = row[1]
default:
logger("func.go:259 -> switch-case is out of range")
}
}
return *output
}
func readHttpYML() string {
file := fileRead("./config/http.yml")
rows := [][]string{}
for _, row := range strings.Split(file, "\n") {
rows = append(rows, strings.Split(row, ": "))
}
for i, row := range rows {
switch i {
case 0:
return row[1]
default:
logger("func.go:280 -> switch-case is out of range")
}
}
return ""
}