Monday, December 9, 2013

I have an internal API that returns io.ReadCloser and I wanted to wrap in a charset decoder. I found the excellent library, but it only provides an io.Reader.

However, I found that's it's quite easy to create a simple pass-through io.ReadCloser with anonymous structs withs anonymous fields:

  rc := struct {
  }{mahonia.NewDecoder("latin2").NewReader(r), r}