Skip to content

Commit

Permalink
del flag parse
Browse files Browse the repository at this point in the history
  • Loading branch information
Chystik committed Oct 26, 2023
1 parent 70105fd commit 11b15aa
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
7 changes: 5 additions & 2 deletions cmd/gophermart/env.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
package main

import (
"os"

"github.com/Chystik/gophermart/config"

"github.com/caarlos0/env"
"github.com/joho/godotenv"
)

func parseEnv(cfg *config.App) error {
/* if osEnv := os.Getenv("ENVIRONMENT"); osEnv == "dev" {
if osEnv := os.Getenv("ENVIRONMENT"); osEnv == "dev" {
err := godotenv.Load(".env.dev")
if err != nil {
return err
}
} */
}
return env.Parse(cfg)
}
4 changes: 2 additions & 2 deletions cmd/gophermart/flags.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package main

import (
/* import (
"flag"
"strings"
Expand All @@ -17,4 +17,4 @@ func parseFlags(cfg *config.App) {
cfg.Address = strings.TrimPrefix(addr, "http://")
cfg.AccrualAddress = strings.TrimPrefix(accr, "http://")
}
} */
5 changes: 2 additions & 3 deletions cmd/gophermart/main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package main

import (
"log"
"os"
"os/signal"
"syscall"
Expand All @@ -13,11 +12,11 @@ import (
func main() {
cfg := config.NewAppConfig()

parseFlags(cfg)
err := parseEnv(cfg)
if err != nil {
log.Fatalln(err)
panic(err)
}
//parseFlags(cfg)

// Graceful shutdown setup
quit := make(chan os.Signal, 1)
Expand Down

0 comments on commit 11b15aa

Please sign in to comment.