<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0"><channel><atom:link rel="hub" href="http://tumblr.superfeedr.com/" xmlns:atom="http://www.w3.org/2005/Atom"/><description>Best practices in Go.</description><title>Good Go</title><generator>Tumblr (3.0; @good-go)</generator><link>http://good-go.tumblr.com/</link><item><title>[]T is not []I</title><description>&lt;p&gt;It&amp;#8217;s bothered me for a while now that in Go I can&amp;#8217;t assign a &lt;code&gt;[]T&lt;/code&gt; to an &lt;code&gt;[]I&lt;/code&gt;, where &lt;code&gt;T&lt;/code&gt; is a concrete type implementing the &lt;code&gt;I&lt;/code&gt; interface. But recently I learned of a very good reason. Consider this code:&lt;/p&gt;
&lt;pre&gt;type Shape interface {
	Area() int
}

type Circle interface {
	Area() int
	Radius() int
}

type Square interface {
	Area() int
	Width() int
	Height() int
}

func main() {
	var circles []Circle = getCircles()

	AddShapeToCollection(circles)

	for _, circle := range circles {
		r := circle.Radius()
		print(r)
	}
}

fund AddShapeToCollection(shapes []Shape) {
	var square Square = getSquare()
	append(shapes, square)
}
&lt;/pre&gt;
&lt;p&gt;What is the &amp;#8220;correct&amp;#8221; behavior here? If we want to keep type safety, there is none. The only sane option is to realize a &lt;code&gt;[]Circle&lt;/code&gt; is not a &lt;code&gt;[]Square&lt;/code&gt;.&lt;/p&gt;</description><link>http://good-go.tumblr.com/post/20307011100</link><guid>http://good-go.tumblr.com/post/20307011100</guid><pubDate>Sun, 01 Apr 2012 16:50:48 -0400</pubDate></item></channel></rss>
