func Filter(src string, filter func(int, []byte) error) error {
	return Read(src, func(fd *os.File) (err error) {
		return io2.FilterRead(fd, filter)
	})
}
Filter file content with given filter, file is in ReadOnly mode
package file
import (
	"io"
	"io/ioutil"
	"os"
	"path/filepath"
	"github.com/cosiner/gohper/errors"
	"github.com/cosiner/gohper/io2"
)
const ErrDestIsFile = errors.Err("destination is a file")
type FileOpFunc func(*os.File) error
func Open(fname string, flags int, fn FileOpFunc) error {
	fd, err := os.OpenFile(fname, flags, FilePerm)
	if err != nil {
		return err
	}
	if fn != nil {
		err = fn(fd)
	}
	if e := fd.Close(); e != nil && err == nil {
		err = e
	}
	return io2.NonEOF(err)
}
func WriteFlag(trunc bool) int {
	if trunc {
		return os.O_TRUNC
	}
	return os.O_APPEND
}
func FirstLine(src string) (line string, err error) {
	err = Filter(src, func(_ int, l []byte) (error) {
		line = string(l)
		return io.EOF
	})
	return
}