now reading from a files directory
This commit is contained in:
+20
-5
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user