Skip to content

Commit

Permalink
Add configuration reading from .env file
Browse files Browse the repository at this point in the history
  • Loading branch information
askolesov committed Apr 20, 2022
1 parent ce94577 commit 9c60d38
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,20 @@ import (

func main() {
viper.SetConfigFile("config.yaml")
viper.SetConfigType("env")
viper.AutomaticEnv()

err := viper.ReadInConfig()
if err != nil { // Handle errors reading the config file
panic(fmt.Errorf("Fatal error config file: %w \n", err))
}

viper.SetConfigFile(".env")
err := viper.ReadInConfig()
if err != nil { // Handle errors reading the config file
panic(fmt.Errorf("Fatal error config file: %w \n", err))
}

viper.AutomaticEnv()


didResolutionPath := viper.GetString("path")
didResolutionListener := viper.GetString("listener")

Expand Down

0 comments on commit 9c60d38

Please sign in to comment.