Skip to content

Commit

Permalink
fix: consul load config error not returned
Browse files Browse the repository at this point in the history
  • Loading branch information
chennqqi committed Nov 5, 2020
1 parent 0b88698 commit 66409d9
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions consul.v2/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func ReadTxt(c *ConsulOperator, file string) ([]byte, error) {
// ${appname}.yml, config/${appname} will be tried to load in order
func NewConsulAppWithCfg(cfg interface{}, consulUrl string) (*ConsulApp, error) {
var capp ConsulApp

if consulUrl == "" {
consulUrl = "127.0.0.1:8500"
}
Expand Down Expand Up @@ -108,7 +108,10 @@ func NewConsulAppWithCfg(cfg interface{}, consulUrl string) (*ConsulApp, error)
txt, err := consulapi.Get(names[i])
if err == nil {
log.Printf("[consul/app.go] successfully get consul kv: %v", names[i])
yaml.Unmarshal(txt, cfg)
err = yaml.Unmarshal(txt, cfg)
if err != nil {
return &capp, err
}
exist = true
break
} else {
Expand Down

0 comments on commit 66409d9

Please sign in to comment.