func (f *memFile) Seek(offset int64, whence int) (ret int64, err error) {
	switch whence {
	default:
		return 0, errWhence
	case os.SEEK_SET:
	case os.SEEK_CUR:
		offset += f.offset
	case os.SEEK_END:
		offset += int64(len(f.fi.content))
	}
	if offset < 0 || int(offset) > len(f.fi.content) {
		return 0, errOffset
	}
	f.offset = offset
	return f.offset, nil
}
Read bytes from the compressed file bytes by seeker.
package beego
import (
	"bytes"
	"compress/flate"
	"compress/gzip"
	"errors"
	"io"
	"io/ioutil"
	"net/http"
	"os"
	"strings"
	"sync"
	"time"
)
var gmfim map[string]*memFileInfo = make(map[string]*memFileInfo)
var lock sync.RWMutex
func openMemZipFile(path string, zip string) (*memFile, error) {
	osfile, e := os.Open(path)
	if e != nil {
		return nil, e
	}
	defer osfile.Close()
	osfileinfo, e := osfile.Stat()
	if e != nil {
		return nil, e
	}
	modtime := osfileinfo.ModTime()
	fileSize := osfileinfo.Size()
	lock.RLock()
	cfi, ok := gmfim[zip+":"+path]
	lock.RUnlock()
	if !(ok && cfi.ModTime() == modtime && cfi.fileSize == fileSize) {
		var content []byte
		if zip == "gzip" {
			var zipbuf bytes.Buffer
			gzipwriter, e := gzip.NewWriterLevel(&zipbuf, gzip.BestCompression)
			if e != nil {
				return nil, e
			}
			_, e = io.Copy(gzipwriter, osfile)
			gzipwriter.Close()
			if e != nil {
				return nil, e
			}
			content, e = ioutil.ReadAll(&zipbuf)
			if e != nil {
				return nil, e
			}
		} else if zip == "deflate" {
			var zipbuf bytes.Buffer
			deflatewriter, e := flate.NewWriter(&zipbuf, flate.BestCompression)
			if e != nil {
				return nil, e
			}
			_, e = io.Copy(deflatewriter, osfile)
			deflatewriter.Close()
			if e != nil {
				return nil, e
			}
			content, e = ioutil.ReadAll(&zipbuf)
			if e != nil {
				return nil, e
			}
		} else {
			content, e = ioutil.ReadAll(osfile)
			if e != nil {
				return nil, e
			}
		}
		cfi = &memFileInfo{osfileinfo, modtime, content, int64(len(content)), fileSize}
		lock.Lock()
		defer lock.Unlock()
		gmfim[zip+":"+path] = cfi
	}
	return &memFile{fi: cfi, offset: 0}, nil
}
type memFileInfo struct {
	os.FileInfo
	modTime     time.Time
	content     []byte
	contentSize int64
	fileSize    int64
}
func (fi *memFileInfo) Name() string {
	return fi.Name()
}
func (fi *memFileInfo) Size() int64 {
	return fi.contentSize
}
func (fi *memFileInfo) Mode() os.FileMode {
	return fi.Mode()
}
func (fi *memFileInfo) ModTime() time.Time {
	return fi.modTime
}
func (fi *memFileInfo) IsDir() bool {
	return fi.IsDir()
}
func (fi *memFileInfo) Sys() interface{} {
	return nil
}
type memFile struct {
	fi     *memFileInfo
	offset int64
}
func (f *memFile) Close() error {
	return nil
}
func (f *memFile) Stat() (os.FileInfo, error) {
	return f.fi, nil
}
func (f *memFile) Readdir(count int) ([]os.FileInfo, error) {
	infos := []os.FileInfo{}
	return infos, nil
}
func (f *memFile) Read(p []byte) (n int, err error) {
	if len(f.fi.content)-int(f.offset) >= len(p) {
		n = len(p)
	} else {
		n = len(f.fi.content) - int(f.offset)
		err = io.EOF
	}
	copy(p, f.fi.content[f.offset:f.offset+int64(n)])
	f.offset += int64(n)
	return
}
var errWhence = errors.New("Seek: invalid whence")
var errOffset = errors.New("Seek: invalid offset")