narratio/main.go

45 lines
681 B
Go
Raw Normal View History

2023-12-15 07:18:39 +01:00
package main
2023-12-15 07:58:31 +01:00
import (
"fmt"
"os"
"path/filepath"
)
2024-09-17 07:44:26 +02:00
type File struct {
2023-12-15 07:58:31 +01:00
Path string
}
2023-12-15 07:18:39 +01:00
func main() {
2024-09-17 07:44:26 +02:00
scenes, err := getScenes()
2023-12-15 07:58:31 +01:00
if err != nil {
2024-09-17 07:44:26 +02:00
fmt.Println(err)
os.Exit(1)
2023-12-15 07:58:31 +01:00
}
2024-09-17 07:44:26 +02:00
for _, scene := range scenes {
fmt.Println(scene.Path)
2023-12-15 07:58:31 +01:00
}
}
2024-09-17 07:44:26 +02:00
func getScenes() ([]File, error) {
scenes := make([]File, 0)
2023-12-15 07:58:31 +01:00
root := "content"
err := filepath.Walk(root, func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
}
if !info.IsDir() {
if filepath.Ext(path) == ".md" {
2024-09-17 07:44:26 +02:00
scenes = append(scenes, File{Path: path})
2023-12-15 07:58:31 +01:00
}
}
return nil
})
if err != nil {
fmt.Printf("error walking the path %v: %v\n", root, err)
}
return scenes, nil
2023-12-15 07:18:39 +01:00
}