Skip to content

Release Notes v0.4.0

Released: 2026-06-13

Highlights

Cross-platform executable detection for file permission checks.

New Features

fs.IsExecutable

Detect whether a file is executable in a cross-platform way.

Problem solved: On Unix, executability is determined by permission bits (0111). On Windows, there are no permission bits; executability is determined by file extension (.exe, .bat, .cmd, etc.).

Key Functions

Function Description
IsExecutable(path) Check if file at path is executable
IsExecutableInfo(info) Check executability using existing fs.FileInfo

Example Usage

import "github.com/grokify/oscompat/fs"

// Check by path
if fs.IsExecutable("/usr/bin/git") {
    fmt.Println("git is executable")
}

// Check with existing FileInfo (avoids extra stat call)
info, _ := os.Stat(path)
if fs.IsExecutableInfo(info) {
    fmt.Println("file is executable")
}

Platform Behavior

Platform How Executability is Determined
Unix/Linux/macOS File has execute permission (mode & 0111 != 0)
Windows File extension is .exe, .bat, .cmd, .com, or .ps1

Installation

go get github.com/grokify/oscompat@v0.4.0