Skip to content

Commit

Permalink
新增:通过环境变量fsenv,支持多环境配置文件
Browse files Browse the repository at this point in the history
  • Loading branch information
steden committed Dec 13, 2023
1 parent 0df0219 commit 0ee43f3
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion configure/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,18 @@ package configure
import (
"fmt"
"github.com/farseer-go/fs/parse"
"os"
"strings"
)

// InitConfig 初始化配置文件
func InitConfig() {
configurationBuilder.AddYamlFile("./farseer.yaml")
ymlFile := "./farseer.yaml"
fsenv := os.Getenv("fsenv")
if fsenv != "" {
ymlFile = fmt.Sprintf("./farseer.%s.yaml", fsenv)
}
configurationBuilder.AddYamlFile(ymlFile)
configurationBuilder.AddEnvironmentVariables()
// 配置文件,我们都是通过a.b访问的。而环境变量是a_b。
// 让环境变量支持a.b的方式,使用替换的方式以支持。
Expand Down

0 comments on commit 0ee43f3

Please sign in to comment.