package installer import ( "fmt" "os" ) func validateNonEmptyRegularFile(path string, requireExecutable bool) error { info, err := os.Lstat(path) if err != nil { return err } if !info.Mode().IsRegular() || info.Mode()&os.ModeSymlink != 0 || info.Size() == 0 { return fmt.Errorf("%s is not a non-empty regular file", path) } if requireExecutable && info.Mode().Perm()&0111 == 0 { return fmt.Errorf("%s is not executable", path) } return nil }