narratio/main.go

45 lines
681 B
Go

package main
import (
"fmt"
"os"
"path/filepath"
)
type File struct {
Path string
}
func main() {
scenes, err := getScenes()
if err != nil {
fmt.Println(err)
os.Exit(1)
}
for _, scene := range scenes {
fmt.Println(scene.Path)
}
}
func getScenes() ([]File, error) {
scenes := make([]File, 0)
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" {
scenes = append(scenes, File{Path: path})
}
}
return nil
})
if err != nil {
fmt.Printf("error walking the path %v: %v\n", root, err)
}
return scenes, nil
}