copied from http://play.golang.org/p/eGRSgZqJyQ and it looks fun