Golang News http://golangnews.com Jobs, Code, Videos and News for Go hackers - everything about the go programming language Wed, 09 Aug 2017 20:19:00 +0000 Go experience report: the append function #generics #append #go2 <p class="postmeta">Ian Lance Taylor talks about adding the append function.&nbsp;When the Go language was first publicly released it contained a package named container/vector. &nbsp;The type <code style="font-family: monospace; color: rgb(102, 102, 102);">vector.Vector</code>&nbsp;was a name for the type <code style="font-family: monospace; color: rgb(102, 102, 102);">[]interface{}</code>. <code style="font-family: monospace; color: rgb(102, 102, 102);">Vector</code>&nbsp;supported methods like <code style="font-family: monospace; color: rgb(102, 102, 102);">Len</code>, <code style="font-family: monospace; color: rgb(102, 102, 102);">Cap</code>, <code style="font-family: monospace; color: rgb(102, 102, 102);">At</code>, <code style="font-family: monospace; color: rgb(102, 102, 102);">Set</code>, <code style="font-family: monospace; color: rgb(102, 102, 102);">Insert</code>, <code style="font-family: monospace; color: rgb(102, 102, 102);">Delete</code>, <code style="font-family: monospace; color: rgb(102, 102, 102);">Push</code>, <code style="font-family: monospace; color: rgb(102, 102, 102);">Pop</code>, and several more. &nbsp;You can see the source code at <a href="https://github.com/golang/go/tree/059c68bf0cccea85bea19c44c15d7fec9e9cbd21/src/pkg/container/vector" style="font-size: 1.2rem; color: rgb(185, 111, 23);">on Github</a>. &nbsp;An interesting aspect of the package is that <code style="font-family: monospace; color: rgb(102, 102, 102);">string</code>&nbsp;and <code style="font-family: monospace; color: rgb(102, 102, 102);">int</code>&nbsp;versions of <code style="font-family: monospace; color: rgb(102, 102, 102);">Vector</code>&nbsp;were automatically generated by copying the file vector.go with edits applied by gofmt -r.</p><div class="postentry"><div><br></div></div> 10 points posted by kenny https://www.airs.com/blog/archives/559 2409 Tue, 18 Jul 2017 06:14:00 +0000