reading from an env file
This commit is contained in:
@@ -0,0 +1,5 @@
|
|||||||
|
# HTTP Settings
|
||||||
|
PORT=8080
|
||||||
|
|
||||||
|
# App Settings
|
||||||
|
STORAGE_PATH=files
|
||||||
+18
-2
@@ -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)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user