<p>In <a href="https://github.com/kubernetes/kubernetes/blob/master/pkg/kubectl/run.go#L59" rel="nofollow noreferrer"><code>kubectl/run.go</code></a> in Kubernetes code, the <code>Generate</code> function has a result list of these two types:</p>
<pre><code>runtime.Object, error
</code></pre>
<p>The last line of the function is:</p>
<pre><code>return &amp;deployment, nil
</code></pre>
<p><code>runtime</code> is imported:</p>
<pre><code>k8s.io/apimachinery/pkg/runtime
</code></pre>
<p>I got <code>runtime</code> by running <code>go get</code> on that import statement, and Object is defined in <code>interfaces.go</code>:</p>
<pre><code>type Object interface {
    GetObjectKind() schema.ObjectKind
    DeepCopyObject() Object
}
</code></pre>
<p>(And I found the same code on the web <a href="https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/apimachinery/pkg/runtime/interfaces.go" rel="nofollow noreferrer">here</a>.)</p>
<p>The address operator creates a pointer... more specifically, the Go spec states:</p>
<blockquote>
<p>For an operand x of type T, the address operation &amp;x generates a pointer of type *T to x.</p>
</blockquote>
<p>and pointers <a href="https://golang.org/ref/spec#Pointer_types" rel="nofollow noreferrer">have a type distinct from their base type</a>:</p>
<blockquote>
<p>A pointer type denotes the set of all pointers to variables of a given type, called the base type of the pointer.</p>
</blockquote>
<p>How does <code>&amp;deployment</code> satisfy the <code>runtime.Object</code> type?</p>
<p>My best guess so far is that <code>deployment</code> implements the <code>runtime.Object</code> interface, and mapping <code>&amp;deployment</code> to <code>runtime.Object</code> satisfies <a href="https://golang.org/ref/spec#Assignability" rel="nofollow noreferrer">this rule of assignability</a>:</p>
<blockquote>
<p>T is an interface type and x implements T.</p>
</blockquote>
<p>and that a return statement mapping to a result list type is equivalent to assignment in this respect.  Is this correct?  If not, is there another part of the specification or documentation that explains it?</p>

<p><code>deployment</code> is a local variable, its declaration:</p>
<pre><code>deployment := extensionsv1beta1.Deployment{
    // ...
}
</code></pre>
<p>Where <code>extensionsv1beta1</code> from the imports:</p>
<pre><code>import (
    // ...
    extensionsv1beta1 &quot;k8s.io/api/extensions/v1beta1&quot;
    // ...
)
</code></pre>
<p>Doc of <a href="https://godoc.org/k8s.io/api/extensions/v1beta1#Deployment" rel="nofollow noreferrer"><code>extensionsv1beta1.Deployment</code></a>. Its definition is:</p>
<pre><code>type Deployment struct {
    metav1.TypeMeta `json:&quot;,inline&quot;`
    // ...other fields...
}
</code></pre>
<p>It embeds <a href="https://godoc.org/k8s.io/apimachinery/pkg/apis/meta/v1#TypeMeta" rel="nofollow noreferrer"><code>metav1.TypeMeta</code></a>, which has a method <a href="https://godoc.org/k8s.io/apimachinery/pkg/apis/meta/v1#TypeMeta.GetObjectKind" rel="nofollow noreferrer"><code>GetObjectKind()</code></a> method with pointer receiver. This means a pointer to <code>Deployment</code> also has this method, because <a href="https://golang.org/ref/spec#Struct_types" rel="nofollow noreferrer">Spec: Struct types:</a></p>
<blockquote>
<p>Given a struct type <code>S</code> and a defined type <code>T</code>, promoted methods are included in the method set of the struct as follows:</p>
<ul>
<li>If <code>S</code> contains an embedded field <code>T</code>, the method sets of <code>S</code> and <code>*S</code> both include promoted methods with receiver <code>T</code>. <strong>The method set of <code>*S</code> also includes promoted methods with receiver <code>*T</code>.</strong></li>
</ul>
</blockquote>
<p>And <code>Deployment</code> has a &quot;direct&quot; <a href="https://godoc.org/k8s.io/api/extensions/v1beta1#Deployment.DeepCopyObject" rel="nofollow noreferrer"><code>DeepCopyObject()</code></a> method, again with pointer receiver. So the <a href="https://golang.org/ref/spec#Method_sets" rel="nofollow noreferrer">method set</a> of <code>*Deployment</code> contains this method.</p>
<p>And last quoting <a href="https://golang.org/ref/spec#Interface_types" rel="nofollow noreferrer">Spec: Interface types:</a></p>
<blockquote>
<p>An interface type specifies a <a href="https://golang.org/ref/spec#Method_sets" rel="nofollow noreferrer">method set</a> called its <em>interface</em>. <strong>A variable of interface type can store a value of any type with a method set that is any superset of the interface.</strong> Such a type is said to <em>implement the interface</em>.</p>
</blockquote>
<p>So this means the method set of <code>*Deployment</code> has all the methods defined by <code>Object</code>, or in other words: the method set of <code>*Deployment</code> is a superset of the method set of <code>Object</code>, so <code>*Deployment</code> implements <code>Object</code>.</p>
<p><code>deployment</code> is of type <code>extensionsv1beta1.Deployment</code>, which means <code>&amp;deployment</code> is of type <code>*extensionsv1beta1.Deployment</code>, which we showed above that it implements <code>Object</code>; so the value <code>&amp;deployment</code> can be assigned to or be stored in a variable of type <code>Object</code>.</p>
