knowyt/server/src/application/loadQuotes.go

30 lines
500 B
Go
Raw Normal View History

package application
import (
"os"
"path"
"sirlab.de/go/knyt/game"
"sirlab.de/go/knyt/quote"
)
func (app Application) loadQuotes(gm *game.Game, dirName string) error {
quoteDirName := path.Join(dirName, "quotes")
files, err := os.ReadDir(quoteDirName)
if err != nil {
return err
}
for _, file := range files {
fileName := path.Join(quoteDirName, file.Name())
quote, err := quote.NewQuoteFromFile(fileName)
if err != nil {
return err
}
gm.AddQuote(quote)
}
return nil
}