From c8997702161e0e24b461b87d8b35801f0f3f8207 Mon Sep 17 00:00:00 2001 From: Xargin Date: Tue, 21 Aug 2018 16:34:20 +0800 Subject: [PATCH] update dc --- ch6-cloud/ch6-06-config.md | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/ch6-cloud/ch6-06-config.md b/ch6-cloud/ch6-06-config.md index dfab6f0..d52c6b1 100644 --- a/ch6-cloud/ch6-06-config.md +++ b/ch6-cloud/ch6-06-config.md @@ -100,12 +100,12 @@ var configPath = `/configs/remote_config.json` var kapi client.KeysAPI type ConfigStruct struct { - Addr string `json:"addr"` - AesKey string `json:"aes_key"` - HTTPS bool `json:"https"` - Secret string `json:"secret"` - PrivateKeyPath string `json:"private_key_path"` - CertFilePath string `json:"cert_file_path"` + Addr string `json:"addr"` + AesKey string `json:"aes_key"` + HTTPS bool `json:"https"` + Secret string `json:"secret"` + PrivateKeyPath string `json:"private_key_path"` + CertFilePath string `json:"cert_file_path"` } var appConfig ConfigStruct @@ -118,10 +118,11 @@ func init() { } c, err := client.New(cfg) - if err != nil { - log.Fatal(err) - } - kapi = client.NewKeysAPI(c) + if err != nil { + log.Fatal(err) + } + kapi = client.NewKeysAPI(c) + initConfig() } func watchAndUpdate() { @@ -143,7 +144,7 @@ func watchAndUpdate() { }() } -func getConfig() { +func initConfig() { resp, err = kapi.Get(context.Background(), configPath, nil) if err != nil { log.Fatal(err) @@ -155,6 +156,10 @@ func getConfig() { } } +func getConfig() ConfigStruct { + return appConfig +} + func main() { // init your app }