now reading from a files directory

This commit is contained in:
2026-05-06 21:50:31 -06:00
parent 420cf6711e
commit 3b84e46c93
3 changed files with 20 additions and 5 deletions
+20 -5
View File
@@ -8,13 +8,26 @@ import (
"github.com/joho/godotenv"
)
func resolveFileStorePath(path string) {
err := os.MkdirAll(path, os.ModePerm)
func resolveFileStorePath(file_store_path string) {
err := os.MkdirAll(file_store_path, os.ModePerm)
if err != nil {
log.Fatal(err)
}
}
func readFilesFromFileStorePath(file_store_path string) {
files, err := os.ReadDir(file_store_path)
if err != nil {
log.Fatal(err)
}
for _, file := range files {
if !file.IsDir() {
fmt.Println(file.Name())
}
}
}
func main() {
err := godotenv.Load()
if err != nil {
@@ -23,10 +36,12 @@ func main() {
port := os.Getenv("PORT")
storage_path := os.Getenv("STORAGE_PATH")
file_store_path := os.Getenv("STORAGE_PATH")
resolveFileStorePath(storage_path)
resolveFileStorePath(file_store_path)
fmt.Printf("in the future I will listen on port: %s\n", port)
fmt.Printf("Reading files from: %s\n", storage_path)
fmt.Printf("Reading files from: %s\n", file_store_path)
readFilesFromFileStorePath(file_store_path)
}