48 lines
826 B
Go
48 lines
826 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"log"
|
|
"os"
|
|
|
|
"github.com/joho/godotenv"
|
|
)
|
|
|
|
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 {
|
|
log.Fatal("Error loading .env file")
|
|
}
|
|
|
|
port := os.Getenv("PORT")
|
|
|
|
file_store_path := os.Getenv("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", file_store_path)
|
|
|
|
readFilesFromFileStorePath(file_store_path)
|
|
}
|