<p>I'm struggling with the Kubernetes Go library.  The docs--<a href="https://github.com/kubernetes/kubernetes/blob/master/pkg/client/unversioned/doc.go">at least the ones I found</a>--appear out-of-date with the library itself.  The example provided does not build because of issues with the imports.  I'm just trying to do something simple: get a Service object by name and print some attributes (like nodePort).  I just need a simple example of library usage to get me going.</p>

<p>I could easily do this using the RESTful API but that feels like re-inventing the wheel.</p>

<p>So after a little experimentation and a hint from the k8s Slack channel, I have this example.  Perhaps someone can update the example with a proper import path.</p>

<pre><code>package main

import (
    "fmt"
    "log"

    "github.com/kubernetes/kubernetes/pkg/api"
    client "github.com/kubernetes/kubernetes/pkg/client/unversioned"
)

func main() {

    config := client.Config{
        Host: "http://my-kube-api-server.me:8080",
    }
    c, err := client.New(&amp;config)
    if err != nil {
        log.Fatalln("Can't connect to Kubernetes API:", err)
    }

    s, err := c.Services(api.NamespaceDefault).Get("some-service-name")
    if err != nil {
        log.Fatalln("Can't get service:", err)
    }
    fmt.Println("Name:", s.Name)
    for p, _ := range s.Spec.Ports {
        fmt.Println("Port:", s.Spec.Ports[p].Port)
        fmt.Println("NodePort:", s.Spec.Ports[p].NodePort)
    }
}
</code></pre>
