Golang News http://golangnews.com Jobs, Code, Videos and News for Go hackers - everything about the go programming language Fri, 23 Mar 2018 03:54:00 +0000 On generics in Go #generics By Ian Lance Taylor. Go should support some form of generic programming. Generic programming enables the representation of algorithms and data structures in a generic form, with concrete elements of the code (such as types) factored out. It means the ability to express algorithms with minimal assumptions about data structures, and vice-versa 12 points posted by kenny https://github.com/golang/proposal/blob/master/design/15292-generics.md 1500 Mon, 09 Jan 2017 22:14: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 Dealing with the lack of Generics in Go #generics 7 points posted by kenny https://appliedgo.net/generics 965 Fri, 29 Jul 2016 13:15:00 +0000 Ian Lance Taylor discusses the Go Generics draft on golang nuts #generics I thought this was an interesting discussion about the difficulties with the current draft, and other solutions proposed.&nbsp; 6 points posted by tomf https://groups.google.com/forum/#!topic/golang-nuts/Oqr2cs0isz0 3545 Fri, 07 Sep 2018 22:59:00 +0000 GenX: Generics For Go, Yet Again. #generics #go2 A slightly more powerful generic code generator with a very simple interface.<br><br><div><b>Features: </b></div><div><pre style="word-wrap: break-word; white-space: pre-wrap;"> <ul><li>* It can be *easily* used with `go generate`, from the command line or as a library.</li> <li>* `cmd/genx` Uses local files, packages, and optionally uses `go get` (with the `-get` flag) if the remote package doesn't exist.</li> <li>* You can rewrite, remove and change pretty much everything.</li> <li>* Allows you to merge a package of multiple files into a single one.</li> <li>* *Safely* remove functions and struct fields.</li> <li>* Automatically passes all code through `x/tools/imports` (aka `goimports`).</li> <li>* If you intend on generating files in the same package, you may add `// +build genx` to your template(s).</li> <li>* Transparently handles [genny](https://github.com/cheekybits/genny)'s `generic.Type`.</li> <li>* Supports a few [seeds](https://github.com/OneOfOne/genx/tree/master/seeds/).</li> <li>* Adds build tags based on the types you pass, so you can target specifc types (ex: `// +build genx_t_string` or `// +build genx_vt_builtin` )</li> <li>* Automatically handles nil returns, will return the zero value of the type.</li> <li>* Doesn't need modifying the source package if there's only one type involved.</li> </ul></pre></div> 4 points posted by OneOfOne https://github.com/OneOfOne/genx 2582 Sun, 27 Aug 2017 13:53:00 +0000 Summary of Go generics discussions #generics 3 points posted by kenny https://docs.google.com/document/d/1vrAy9gMpMoS3uaVphB32uVXX4pi-HnNjkMEgyAHX4N4/preview?pli=1 426 Thu, 19 Nov 2015 08:55:00 +0000 Summary of Go Generics Discussions #generics 3 points posted by kenny https://docs.google.com/document/d/1vrAy9gMpMoS3uaVphB32uVXX4pi-HnNjkMEgyAHX4N4/preview 280 Fri, 16 Oct 2015 12:08:00 +0000