code: func DetectFileType(r io.Reader) (FileType, error) {
  	var b bytes.Buffer
  	n, err := io.CopyN(&b, r, readLen)
  	if err != nil && err != io.EOF {
  		return TypeUnknown, err
  	}
  	bs := b.Bytes()
  	switch {
  	case bytes.HasPrefix(bs, hdrGzip):
  		return TypeGzip, nil
  	case bytes.HasPrefix(bs, hdrBzip2):
  		return TypeBzip2, nil
  	case bytes.HasPrefix(bs, hdrXz):
  		return TypeXz, nil
  	case n > int64(tarEnd) && bytes.Equal(bs[tarOffset:tarEnd], sigTar):
  		return TypeTar, nil
  	case http.DetectContentType(bs) == textMime:
  		return TypeText, nil
  	default:
  		return TypeUnknown, nil
  	}
  }
docs: // DetectFileType attempts to detect the type of file that the given reader
  // represents by comparing it against known file signatures (magic numbers)