added buf.go borrowed from https://github.com/lib/pq