Skip to content

Commit

Permalink
Finish FixFile
Browse files Browse the repository at this point in the history
  • Loading branch information
zouyx committed Sep 20, 2018
2 parents 18f712d + 61cdf27 commit d3e2553
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ go get -u github.com/zouyx/agollo
* 实时同步配置
* 灰度配置
* 客户端容灾
* 配置文件容灾 (v1.6.0+)

# Usage

Expand Down
4 changes: 2 additions & 2 deletions file.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ func writeConfigFile(config *ApolloConfig,configPath string)error{
return errors.New("apollo config is null can not write backup file")
}
file, e := os.Create(getConfigFile(configPath))
defer file.Close()
if e!=nil{
logger.Errorf("writeConfigFile fail,error:",e)
return e
}
defer file.Close()

return json.NewEncoder(file).Encode(config)
}
Expand All @@ -44,11 +44,11 @@ func loadConfigFile(configDir string) (*ApolloConfig,error){
configFilePath := getConfigFile(configDir)
logger.Info("load config file from :",configFilePath)
file, e := os.Open(configFilePath)
defer file.Close()
if e!=nil{
logger.Errorf("loadConfigFile fail,error:",e)
return nil,e
}
defer file.Close()
config:=&ApolloConfig{}
e=json.NewDecoder(file).Decode(config)

Expand Down

0 comments on commit d3e2553

Please sign in to comment.