func (w *SizedLogWriter) Close() error {
	if w._f != nil {
		err := w._f.Close()
		w._f = nil
		return err
	}
	return nil
}
Close cleans up the associated resources
package logwriter
import (
	"os"
	"strings"
	"github.com/pkg/errors"
)
const sizedLogWriterDefaultMode os.FileMode = 0644
type SizedLogWriter struct {
	RotateSize int
	Path       string
	FileMode   os.FileMode
	_f *os.File  
}
func (w *SizedLogWriter) Mode() os.FileMode {
	if w.FileMode == 0 {
		return sizedLogWriterDefaultMode
	}
	return w.FileMode
}
func (w *SizedLogWriter) File() (*os.File, error) {
	if w._f != nil {
		return w._f, nil
	}
	f, err := os.OpenFile(w.Path, os.O_CREATE|os.O_RDWR, w.Mode())
	if err != nil {
		return nil, err
	}
	w._f = f
	return w._f, nil
}
func (w *SizedLogWriter) Rotate() error {
	var err error
	if w._f != nil {
		err = w._f.Close()
		if err != nil {
			return err
		}
		w._f = nil
	}
	err = os.Remove(w.Path)
	if err != nil {
		return err
	}
	return nil
}