Skip to content

Resolves build errors on Windows#21

Open
bsormagec wants to merge 1 commit intosteipete:mainfrom
bsormagec:main
Open

Resolves build errors on Windows#21
bsormagec wants to merge 1 commit intosteipete:mainfrom
bsormagec:main

Conversation

@bsormagec
Copy link

This PR resolves build errors on Windows caused by Unix-specific syscall.Flock and updates documentation for Windows users.

Changes

  • File Locking Decoupling:

    • Renamed internal/lock/lock.go to internal/lock/lock_unix.go (added //go:build !windows).
    • Created internal/lock/lock_windows.go with a Windows-compatible implementation that relies on file existence and os.OpenFile exclusion flags effectively, skipping syscall.Flock.
  • Documentation:

    • Updated README.md with a new "Install via Go" option (go install).
    • highlighted Windows support in the installation section.

CI/CD

Existing Windows release workflows in .goreleaser-linux-windows.yaml should now succeed since the platform-specific code compilation issues are resolved.

…call.Flock` and updates documentation for Windows users.

### Changes

- **File Locking Decoupling:**
  - Renamed `internal/lock/lock.go` to `internal/lock/lock_unix.go` (added `//go:build !windows`).
  - Created `internal/lock/lock_windows.go` with a Windows-compatible implementation that relies on file existence and `os.OpenFile` exclusion flags effectively, skipping `syscall.Flock`.

- **Documentation:**
  - Updated `README.md` with a new "Install via Go" option (`go install`).
  - highlighted Windows support in the installation section.

### CI/CD

Existing Windows release workflows in `.goreleaser-linux-windows.yaml` should now succeed since the platform-specific code compilation issues are resolved.
Copilot AI review requested due to automatic review settings February 1, 2026 05:31
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to fix Windows build failures by splitting the store-lock implementation into platform-specific files and updating installation documentation to better support Windows users.

Changes:

  • Added Windows-specific lock implementation under internal/lock/lock_windows.go.
  • Added //go:build !windows constraint to the Unix implementation in internal/lock/lock_unix.go.
  • Updated README.md with a go install installation option and clarified availability of Windows binaries.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
internal/lock/lock_windows.go Introduces a Windows-targeted lock implementation intended to replace Unix-only syscall.Flock.
internal/lock/lock_unix.go Adds a build constraint so Unix locking code is excluded from Windows builds.
README.md Adds a Go-based install option and highlights pre-built binaries for Windows/macOS/Linux.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +21 to +25
path := filepath.Join(storeDir, "LOCK")
f, err := os.OpenFile(path, os.O_CREATE|os.O_RDWR, 0600)
if err != nil {
return nil, fmt.Errorf("open lock file: %w", err)
}
Copy link

Copilot AI Feb 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Acquire on Windows currently does not provide mutual exclusion: os.OpenFile(path, os.O_CREATE|os.O_RDWR, ...) will succeed even when another process already holds the lock file open, so a second process can also “acquire” the lock. This breaks the intended cross-process store lock semantics (and will fail the existing internal/lock/lock_test.go behavior). Implement an actual non-blocking exclusive lock on Windows (e.g., golang.org/x/sys/windows.LockFileEx with LOCKFILE_EXCLUSIVE_LOCK|LOCKFILE_FAIL_IMMEDIATELY, or CreateFile with share mode 0) and return the same "store is locked" error when the lock cannot be taken; also ensure the file is closed on the lock-failure path.

Copilot uses AI. Check for mistakes.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot open a new pull request to apply changes based on this feedback

Comment on lines +5 to +10
import (
"fmt"
"os"
"path/filepath"
"time"
)
Copy link

Copilot AI Feb 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is not gofmt-formatted (spaces instead of tabs in the import block and indentation). Please run gofmt on internal/lock/lock_windows.go to match standard Go formatting used elsewhere in the repo.

Copilot uses AI. Check for mistakes.
@bsormagec
Copy link
Author

@copilot open a new pull request to apply changes based on the comments in this thread

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant