reading from an env file

This commit is contained in:
2026-05-06 21:35:39 -06:00
parent 068625aaad
commit e2ae8f41e9
2 changed files with 23 additions and 2 deletions
+5
View File
@@ -0,0 +1,5 @@
# HTTP Settings
PORT=8080
# App Settings
STORAGE_PATH=files
+18 -2
View File
@@ -1,7 +1,23 @@
package main package main
import "fmt" import (
"fmt"
"log"
"os"
"github.com/joho/godotenv"
)
func main() { func main() {
fmt.Println("Greetings Program") err := godotenv.Load()
if err != nil {
log.Fatal("Error loading .env file")
}
port := os.Getenv("PORT")
storage_path := os.Getenv("STORAGE_PATH")
fmt.Printf("in the future I will listen on port: %s\n", port)
fmt.Printf("Reading files from: %s\n", storage_path)
} }