func (s *Single) CheckLock() error {
	if err := os.Remove(s.Filename()); err != nil && !os.IsNotExist(err) {
		return ErrAlreadyRunning
	}
	file, err := os.OpenFile(s.Filename(), os.O_EXCL|os.O_CREATE, 0600)
	if err != nil {
		return err
	}
	s.file = file
	return nil
}
CheckLock tries to obtain an exclude lock on a lockfile and returns an error if one occurs
package single
import (
	"fmt"
	"os"
	"path/filepath"
)
func (s *Single) Filename() string {
	if len(Lockfile) > 0 {
		return Lockfile
	}
	return filepath.Join(os.TempDir(), fmt.Sprintf("%s.lock", s.name))
}