go-pg/pg — pull request #3 by Babazka (2014-04-18 11:09:07+00:00)
Title: Handle encoding.TextUnmarshaler when decoding values

`pg` package contains a convenient `Appender` interface which makes writing arbitrary data types to Postgres possible. However there is no such interface for the inverse process: decoding arbitrary data types from database.

This pull request proposes using the standard `encoding.TextUnmarshaler` interface (http://golang.org/pkg/encoding/#TextUnmarshaler) for this purpose. An example of what can be achieved with this interface can be seen in supplied unit tests.

P.S. It might make sense to also handle TextMarshaler interface for writing into database. I chose not to implement this, however, because `Appender` already serves this purpose.