Skip to content

Commit 66409d9

Browse files
committed
fix: consul load config error not returned
1 parent 0b88698 commit 66409d9

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

consul.v2/app.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func ReadTxt(c *ConsulOperator, file string) ([]byte, error) {
4646
// ${appname}.yml, config/${appname} will be tried to load in order
4747
func NewConsulAppWithCfg(cfg interface{}, consulUrl string) (*ConsulApp, error) {
4848
var capp ConsulApp
49-
49+
5050
if consulUrl == "" {
5151
consulUrl = "127.0.0.1:8500"
5252
}
@@ -108,7 +108,10 @@ func NewConsulAppWithCfg(cfg interface{}, consulUrl string) (*ConsulApp, error)
108108
txt, err := consulapi.Get(names[i])
109109
if err == nil {
110110
log.Printf("[consul/app.go] successfully get consul kv: %v", names[i])
111-
yaml.Unmarshal(txt, cfg)
111+
err = yaml.Unmarshal(txt, cfg)
112+
if err != nil {
113+
return &capp, err
114+
}
112115
exist = true
113116
break
114117
} else {

0 commit comments

Comments
 (0)