fix goenv

This commit is contained in:
Andre Medeiros 2021-07-05 20:20:00 -04:00
parent 60a9e7deae
commit 7f30f279bc
2 changed files with 8 additions and 10 deletions

View file

@ -28,17 +28,16 @@ type application struct {
}
func main() {
err := godotenv.Load()
if err != nil {
log.Fatal("Error loading .env file")
logger := log.New(os.Stdout, "", log.Ldate|log.Ltime)
if err := godotenv.Load(); err != nil {
logger.Printf("Couldn't find .env so I will read from existing ENV.")
}
var cfg config
flag.IntVar(&cfg.port, "port", 4000, "API server port")
flag.Parse()
logger := log.New(os.Stdout, "", log.Ldate|log.Ltime)
db, err := sql.Open("postgres", os.Getenv("DATABASE_URL"))
if err != nil {
log.Fatal(err)

View file

@ -116,13 +116,12 @@ func accountWorker(id int, rc *reddit.Client, db *sql.DB, logger *log.Logger, qu
}
func main() {
err := godotenv.Load()
if err != nil {
log.Fatal("Error loading .env file")
}
logger := log.New(os.Stdout, "", log.Ldate|log.Ltime)
if err := godotenv.Load(); err != nil {
logger.Printf("Couldn't find .env so I will read from existing ENV.")
}
rc := reddit.NewClient(os.Getenv("REDDIT_CLIENT_ID"), os.Getenv("REDDIT_CLIENT_SECRET"))
db, err := sql.Open("postgres", os.Getenv("DATABASE_URL"))