func (c *GLC) check(files []os.FileInfo) {
	excludes := make(map[string]struct{}, numSeverity)
	for _, f := range files {
		if _, ok := c.symlinks[f.Name()]; ok && f.Mode()&os.ModeSymlink != 0 {
			if dst, err := os.Readlink(c.path + f.Name()); err == nil {
				excludes[dst] = empty
			}
		}
	}
	for _, f := range files {
		if _, ok := excludes[f.Name()]; ok {
			continue
		}
		prefix := strings.HasPrefix(f.Name(), c.prefix)
		str := strings.Split(f.Name(), `.`)
		if prefix && len(str) == 7 && str[3] == `log` {
			c.drop(f)
		}
	}
}
check provides function to check log files name whether the deletion
condition is satisfied.
package glc
import (
	"io/ioutil"
	"os"
	"strings"
	"time"
	"github.com/golang/glog"
)
type severity int32  
const (
	infoLog severity = iota
	warningLog
	errorLog
	fatalLog
	numSeverity = 4
)
var severityName = []string{
	infoLog:    "INFO",
	warningLog: "WARNING",
	errorLog:   "ERROR",
	fatalLog:   "FATAL",
}
var empty = struct{}{}
type GLC struct {
	path     string
	prefix   string
	interval time.Duration
	reserve  time.Duration
	symlinks map[string]struct{}
}
type InitOption struct {
	Path     string
	Prefix   string
	Interval time.Duration
	Reserve  time.Duration
}
func NewGLC(option InitOption) *GLC {
	c := new(GLC)
	c.path = option.Path
	c.interval = option.Interval
	c.prefix = option.Prefix
	c.reserve = option.Reserve
	c.symlinks = make(map[string]struct{}, numSeverity)
	for i := 0; i < numSeverity; i++ {
		symlink := c.prefix + "." + severityName[i]
		c.symlinks[symlink] = empty
	}
	go c.cleaner()
	return c
}
func (c *GLC) clean() {
	exists, err := c.exists(c.path)
	if err != nil {
		glog.Errorln(err)
		return
	}
	if !exists {
		return
	}
	files, err := ioutil.ReadDir(c.path)
	if err != nil {
		glog.Errorln(err)
		return
	}
	c.check(files)
}
func (c *GLC) exists(path string) (bool, error) {
	_, err := os.Stat(path)
	if err == nil {
		return true, nil
	}
	if os.IsNotExist(err) {
		return false, nil
	}
	return true, err
}