<p>I want to watch the change of namespaces in kubernetes cluster, with code like:</p>
<pre><code>        log.Infoln(&quot;====== 1 ======= &quot;)
        namespaces, err := clientset.Namespaces().List(api.ListOptions{Watch: true})
        if err != nil {
            log.Errorln(&quot;Get namespaces from kubernetes cluster error:%v&quot;, err)
        }
        log.Infoln(&quot;====== 2 ======= &quot;)
        for _, namespace := range namespaces.Items {
            log.Println(&quot;=======&gt;&gt; namespaces: &quot;, namespace)
        }
</code></pre>
<p>this code will block at <code>namespaces, err := clientset.Namespaces().List(api.ListOptions{Watch: true})</code>. But there is no response when I create new namespace either delete the namespaces.</p>
<p>the <code>client-go</code> is <code>k8s.io/client-go/1.5/</code></p>
<p>Anyone can give me the example code for this, thanks.</p>

sope
<p>I had foud the answer:</p>

<pre><code>var watch watch.Interface
if watch, err = clientset.Namespaces().Watch(api.ListOptions{Watch: true}); err != nil {
    log.Errorln("Watch namespaces from kubernetes cluster error:%v", err)
    return
}

eventChan := watch.ResultChan()
for event := range eventChan {
    log.Infoln(event)
}
</code></pre>
