Skip to content

diskspace: add build constraints for cross-platform compatibility #472

@aftersnow

Description

@aftersnow

Background

The pkg/diskspace package introduced in #471 uses golang.org/x/sys/unix (unix.Statfs) to check available disk space. This makes the package Unix-only and will cause compilation failures on Windows.

Current State

  • pkg/diskspace/check.go imports golang.org/x/sys/unix without a build constraint
  • Other packages in the project (e.g., pkg/xattr) also use Unix-specific syscalls
  • The project currently only targets Linux and macOS in CI/release

Proposed Change

  1. Add //go:build unix constraint to check.go (rename to check_unix.go)
  2. Create check_other.go with //go:build !unix that returns nil (no-op on unsupported platforms)
  3. This allows the project to compile on Windows without breaking the disk space check on Unix

Priority

Low — the project does not currently support Windows, but adding build constraints is good practice for future portability.

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions