Go FuncCloser pattern
I’ve run quite a few times into this issue lately. I have an io.Reader which wraps another io.Reader but does not offer a way to close the inner io.Reader. One instance of this issue is with the bufio.Reader type. The function below opens the given file, peeks at the first 512 bytes to try to detect the mime type, and then returns an io.ReadCloser to read and then close the file....