Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I've written a fair bit of Go code, and rarely miss generics.

Two Go features in particular help to mitigate the lack of generics:

1. The built-in array/slice and map containers are effectively generic since they can act as containers for any type.

2. Interfaces (http://weekly.golang.org/ref/spec#Interface_types) define a set of common methods that can be implemented by multiple concrete types. See e.g. the ubiquitous io.Reader interface (http://weekly.golang.org/pkg/io/#Reader), and the SQL database driver package (http://weekly.golang.org/pkg/database/sql/driver/) that defines a collection of interfaces that define an interface to any SQL database. FWIW I've written a concrete PostgreSQL driver: https://github.com/jbarham/gopgsqldriver.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: