<p>I'm trying to list knative (v0.17.0) <code>services</code>, I have a <code>clientset</code> but I don't know where to start.
Here is a service I launched for my test :</p>
<pre><code>apiVersion: serving.knative.dev/v1alpha1
kind: Service
metadata:
  name: &quot;helloworld&quot;
spec:
  runLatest:
    configuration:
      revisionTemplate:
        spec:
          container:
            image: &quot;gcr.io/knative-samples/helloworld-go&quot;
            env:
              - name: &quot;TARGET&quot;
                value: &quot;world&quot;
</code></pre>
<p>If you have any advice, tutorial or example it would be great</p>

<p>Basing this off <a href="https://gist.github.com/mhausenblas/30e8dc5f7682888c10906cb0f8c471cb" rel="nofollow noreferrer">this gist</a> adapted for the post-1.18 client-go, and the <a href="https://pkg.go.dev/knative.dev/serving@v0.20.0/pkg/client/clientset/versioned/typed/serving/v1" rel="nofollow noreferrer">Serving <code>clientset</code> godoc</a>:</p>
<pre class="lang-golang prettyprint-override"><code>import (
  &quot;context&quot;
  &quot;fmt&quot;
  metav1 &quot;k8s.io/apimachinery/pkg/apis/meta/v1&quot;
  &quot;k8s.io/client-go/tools/clientcmd&quot;
  servingv1 &quot;knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1&quot;
}

func doIt() error {
  config, err := clientcmd.BuildConfigFromFLags(&quot;&quot;, &quot;&quot;) // Uses defaults
  if err != nil {
    return err
  }

  serving, err := servingv1.NewForConfig(config)
  if err != nil {
    return err
  }

  // Get services in the default namespace
  list, err := serving.Services(&quot;default&quot;).List(context.Background(), metav1.ListOptions{})
  if err != nil {
    return err
  }
  // How to print them out.
  fmt.Printf(&quot;There are %d services in the default namespace&quot;, len(list.Items))
  for _, i := range list.Items {
    fmt.Printf(&quot;  &gt; Service %q&quot;, i.Name)
  }
}
</code></pre>
