Skip to content

Commit

Permalink
Read config from env
Browse files Browse the repository at this point in the history
  • Loading branch information
bbbbbbbbbbbbba committed May 28, 2024
1 parent 6870ef2 commit d472e59
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions server/internal/server/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"fmt"
"log/slog"
"os"
"strings"
"time"

"github.com/mlogclub/simple/common/strs"
Expand Down Expand Up @@ -41,6 +42,9 @@ func initConfig() {
viper.AddConfigPath("$HOME/.bbs-go")
viper.AddConfigPath(".")
viper.AddConfigPath("../../")
viper.AutomaticEnv()
viper.SetEnvPrefix("BBSGO")
viper.SetEnvKeyReplacer(strings.NewReplacer(".", "_"))

if err := viper.ReadInConfig(); err != nil {
panic(fmt.Errorf("fatal error config file: %w", err))
Expand Down

0 comments on commit d472e59

Please sign in to comment.