diff --git a/README_CN.md b/README_CN.md index 9c12bf8..08dfa04 100644 --- a/README_CN.md +++ b/README_CN.md @@ -56,7 +56,7 @@ ```golang agollo.GetStringValue(Key, defaultValue) - agollo.GetStringValueWithNameSapce(namespace, key, defaultValue) + agollo.GetStringValueWithnamespace(namespace, key, defaultValue) ``` ### 获取文件内容 diff --git a/client.go b/client.go index 52f268c..7559dcc 100644 --- a/client.go +++ b/client.go @@ -158,9 +158,9 @@ func (c *Client) GetAllKeys(namespace string) []string { } // sync namespace config -func (c *Client) sync(namesapce string) (*ChangeEvent, error) { - releaseKey := c.GetReleaseKey(namesapce) - url := configURL(c.conf, namesapce, releaseKey) +func (c *Client) sync(namespace string) (*ChangeEvent, error) { + releaseKey := c.GetReleaseKey(namespace) + url := configURL(c.conf, namespace, releaseKey) bts, err := c.requester.request(url) if err != nil || len(bts) == 0 { return nil, err @@ -216,7 +216,7 @@ func (c *Client) handleResult(result *result) *ChangeEvent { c.setReleaseKey(result.NamespaceName, result.ReleaseKey) // dump caches to file - c.dump(c.getDumpFileName()) + _ = c.dump(c.getDumpFileName()) if len(ret.Changes) == 0 { return nil diff --git a/conf_test.go b/conf_test.go index 17d8073..f16b5aa 100644 --- a/conf_test.go +++ b/conf_test.go @@ -30,15 +30,15 @@ func TestNewConf(t *testing.T) { func TestConfNormalize(t *testing.T) { cases := []struct { - namesapces []string + namespaces []string }{ { - namesapces: []string{"a", "b"}, + namespaces: []string{"a", "b"}, }, } for _, c := range cases { - conf := &Conf{NameSpaceNames: c.namesapces} + conf := &Conf{NameSpaceNames: c.namespaces} conf.normalize() if !strIn(conf.NameSpaceNames, defaultNamespace) { t.Fatal("application should be in conf's namespaces") diff --git a/notification.go b/notification.go index 9085ca8..bb6b3af 100644 --- a/notification.go +++ b/notification.go @@ -14,13 +14,13 @@ type notificationRepo struct { notifications sync.Map } -func (n *notificationRepo) addNotificationID(namesapce string, notificationID int) bool { - _, loaded := n.notifications.LoadOrStore(namesapce, notificationID) +func (n *notificationRepo) addNotificationID(namespace string, notificationID int) bool { + _, loaded := n.notifications.LoadOrStore(namespace, notificationID) return !loaded } -func (n *notificationRepo) setNotificationID(namesapce string, notificationID int) { - n.notifications.Store(namesapce, notificationID) +func (n *notificationRepo) setNotificationID(namespace string, notificationID int) { + n.notifications.Store(namespace, notificationID) } func (n *notificationRepo) getNotificationID(namespace string) (int, bool) { diff --git a/poller.go b/poller.go index a5f06f1..51ce374 100644 --- a/poller.go +++ b/poller.go @@ -75,9 +75,11 @@ func (p *longPoller) addNamespaces(namespaces ...string) error { update = true } } + if update { - p.pumpUpdates() + return p.pumpUpdates() } + return nil } @@ -88,7 +90,7 @@ func (p *longPoller) watchUpdates() { for { select { case <-timer.C: - p.pumpUpdates() + _ = p.pumpUpdates() timer.Reset(p.pollerInterval) case <-p.ctx.Done(): diff --git a/request.go b/request.go index 48f4b71..f9324e4 100644 --- a/request.go +++ b/request.go @@ -37,7 +37,7 @@ func (r *httprequester) request(url string) ([]byte, error) { return ioutil.ReadAll(resp.Body) } - // Diacard all body if status code is not 200 + // Discard all body if status code is not 200 _, _ = io.Copy(ioutil.Discard, resp.Body) return nil, ErrorStatusNotOK }