chore: update code

This commit is contained in:
DaanSelen
2026-03-30 16:58:19 +02:00
parent d5844bf28a
commit b0bfe3abce
10 changed files with 311 additions and 14 deletions
+35
View File
@@ -0,0 +1,35 @@
package tasks
import (
"log"
"os"
"strings"
)
func isYaml(filename string) bool {
return strings.HasSuffix(filename, ".yaml") || strings.HasSuffix(filename, ".yml")
}
func ListAvailableBooks() ([]string, error) {
files, err := os.ReadDir("./books")
if err != nil {
log.Printf("failed to read the './books' directory: %v", err)
return []string{}, err
}
foundBooks := []string{}
for _, f := range files {
if f.IsDir() {
continue
}
fName := f.Name()
log.Println(fName)
if isYaml(fName) {
fullRelPath := "./books/" + fName
foundBooks = append(foundBooks, fullRelPath)
}
}
return foundBooks, nil
}