Skip to content

chore: add robotgo go build purego pure go implementation - #781

Merged
vcaesar merged 3 commits into
masterfrom
wayland-win
Jul 7, 2026
Merged

vcaesar merged 3 commits into
masterfrom
wayland-win

Conversation

@vcaesar

@vcaesar vcaesar commented Jul 7, 2026 •

Copy link
Copy Markdown
Member
  • Update robotgo.go and 13 others

Generated with Codg
Assisted-by: claude-fable-5 via Codg codg@atomai.cc

Please provide Issues links to:

Provide test code:

Description

...

Summary by CodeRabbit

  • New Features
    • Added cross-platform purego build support as a cgo-free default across macOS, Windows, and Linux.
    • On Linux, purego can be combined with x11 or libei to select an alternate pure-Go backend.
  • Tests
    • Extended CI to run go test with -tags purego, including Linux coverage for purego,x11 and purego,libei (with CGO_ENABLED=0).
  • Documentation
    • Updated the main and translated “Cgo-free Builds” instructions with -tags purego examples and clarified tag behavior/default backend selection.

- Update robotgo.go and 13 others

Generated with Codg
Assisted-by: claude-fable-5 via Codg <codg@atomai.cc>
Copilot AI review requested due to automatic review settings July 7, 2026 18:49
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@vcaesar vcaesar added this to the v2.0.0 milestone Jul 7, 2026
@coderabbitai

coderabbitai Bot commented Jul 7, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Build constraints were updated to support the purego build tag across platform backends, related Cgo-dependent files and tests now exclude it, CI adds purego test coverage, and the README files document the new tag and its backend-selection behavior.

Changes

Purego Build Tag Introduction

Layer / File(s) Summary
README documentation for purego tag
README.md, lang/README.*
Backend tables, build examples, and explanatory text were updated to describe purego, OS-default pure-Go backends, and Linux combinations with x11 or libei.
Purego backend enablement
darwin.go, robot_mac_test.go, windows_n.go, wayland_n.go
Build constraints and inline build comments were updated so the Darwin, Windows, and Wayland-related pure-Go backends compile under purego where applicable.
Cgo backend and test exclusions for purego
key.go, robot_info_test.go, robotgo.go, robotgo_fn_v1.go, robotgo_mac.go, robotgo_mac_unix.go, robotgo_mac_win.go, robotgo_test.go, robotgo_x11.go
Shared backend and test files were tightened to exclude purego from their build constraints.
Purego workflow coverage
.github/workflows/go.yml
The Go workflow adds a purego test step and a Linux job that runs purego,x11 and purego,libei test commands with CGO_ENABLED=0.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

  • go-vgo/robotgo#774: Related build-tag wiring for Windows and Wayland backend selection.
  • go-vgo/robotgo#778: Related Darwin build-constraint changes for backend selection under new tags.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is largely incomplete: the required English explanation, reasons, and actual test code are missing, and the Description section is just '...'. Fill in the Description section in English, explain the issue and rationale, and include real test code or state why none was needed.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is clearly related to the main change: adding purego build support across robotgo and docs/tests.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch wayland-win

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copilot AI left a comment

Copy link
Copy Markdown

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 adds a new cross-platform build tag (purego) that selects the existing pure-Go backend per target OS (macOS → mac, Windows → win, Linux → wayland) and updates build constraints/docs so the default Cgo backend is excluded when purego is set.

Changes:

  • Add purego as an alternative selector in the pure-Go wrapper entrypoints (darwin.go, windows_n.go, wayland_n.go).
  • Exclude the Cgo backend (and related files/tests) when -tags purego is used.
  • Document the new purego tag in README.md.

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
windows_n.go Accept purego as an alternative to win for selecting the Windows pure-Go wrapper backend.
wayland_n.go Accept purego as an alternative to wayland for selecting the Linux Wayland pure-Go wrapper backend (and exclude x11).
darwin.go Accept purego as an alternative to mac for selecting the macOS pure-Go wrapper backend.
robotgo.go Exclude the default Cgo backend when purego is enabled.
key.go Exclude Cgo-backed keyboard implementation when purego is enabled.
robotgo_x11.go Exclude this backend path when purego is enabled.
robotgo_mac.go Exclude the Cgo macOS implementation when purego is enabled.
robotgo_mac_unix.go Exclude this build path when purego is enabled.
robotgo_mac_win.go Exclude this build path when purego is enabled.
robotgo_fn_v1.go Exclude deprecated v1 aliases when purego is enabled.
robotgo_test.go Exclude these tests when purego is enabled.
robot_info_test.go Exclude the CI-smoke test file when purego is enabled.
robot_mac_test.go Allow mac pure-Go backend tests to run under purego as well as mac.
README.md Document the new purego tag and add build examples.

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

Comment thread README.md
Comment on lines +228 to +232
# Pure-Go default backend per platform, one tag for all targets:
# macOS -> mac, Windows -> win, Linux -> wayland (combine with x11/libei to override)
go build -tags purego ./...
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -tags "purego,x11" ./...

vcaesar added 2 commits July 7, 2026 12:03
- Update README.de.md and 8 others

Generated with Codg
Assisted-by: gpt-5.5 via Codg <codg@atomai.cc>
- Update go.yml

Generated with Codg
Assisted-by: gpt-5.5 via Codg <codg@atomai.cc>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/go.yml:
- Around line 45-46: The checkout steps in this workflow still persist the repo
token by default, which is unnecessary since there is no later git push use.
Update both uses of actions/checkout in the workflow to set persist-credentials
to false, keeping the change tied to the checkout step configuration so the
repository token is not left available after checkout.
- Around line 32-60: The purego CI matrix is incomplete: the existing purego job
should also run the default `go test -v -tags purego .` path on Linux so the
documented wayland default is covered, and the macOS/Windows purego step should
explicitly set `CGO_ENABLED=0` to ensure the no-Cgo path is exercised there too.
Update the workflow job around `Pure Go Test`, `purego-linux`, and the
platform-specific purego step so both the Linux default test and the non-Cgo
environment are included.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 897de848-cadf-4069-83d4-16b4f6dbea01

📥 Commits

Reviewing files that changed from the base of the PR and between 4babc74 and ab48a1a.

📒 Files selected for processing (10)
  • .github/workflows/go.yml
  • lang/README.de.md
  • lang/README.es.md
  • lang/README.fr.md
  • lang/README.ja.md
  • lang/README.ko.md
  • lang/README.pt.md
  • lang/README.ru.md
  • lang/README.zh.md
  • lang/README.zht.md
✅ Files skipped from review due to trivial changes (2)
  • lang/README.pt.md
  • lang/README.zh.md

Comment thread .github/workflows/go.yml
Comment on lines +32 to +60
- name: Pure Go Test
run: go test -v -tags purego .

purego-linux:
runs-on: ubuntu-latest

steps:
- name: Set up Go 1.26.0
uses: actions/setup-go@v6
with:
go-version: 1.26.x
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v6

- name: Get dependencies
run: |
go get -v -t -d ./...

- name: Pure Go X11 Test
run: go test -v -tags "purego,x11" . ./x11
env:
CGO_ENABLED: 0

- name: Pure Go libei Test
run: go test -v -tags "purego,libei" . ./libei
env:
CGO_ENABLED: 0

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

sed -n '1,220p' .github/workflows/go.yml | cat -n

Repository: go-vgo/robotgo

Length of output: 1883


🏁 Script executed:

rg -n "purego|wayland|x11|libei|CGO_ENABLED" .github/workflows go.mod . -g '!**/vendor/**'

Repository: go-vgo/robotgo

Length of output: 50370


Complete the purego CI matrix. Add a Linux go test -v -tags purego . run so the documented default wayland path is exercised, and set CGO_ENABLED=0 on the macOS/Windows purego step to keep the no-Cgo path covered.

🧰 Tools
🪛 zizmor (1.26.1)

[warning] 45-46: credential persistence through GitHub Actions artifacts (artipacked): does not set persist-credentials: false

(artipacked)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/go.yml around lines 32 - 60, The purego CI matrix is
incomplete: the existing purego job should also run the default `go test -v
-tags purego .` path on Linux so the documented wayland default is covered, and
the macOS/Windows purego step should explicitly set `CGO_ENABLED=0` to ensure
the no-Cgo path is exercised there too. Update the workflow job around `Pure Go
Test`, `purego-linux`, and the platform-specific purego step so both the Linux
default test and the non-Cgo environment are included.

Comment thread .github/workflows/go.yml
Comment on lines +45 to +46
- name: Check out code into the Go module directory
uses: actions/checkout@v6

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

git ls-files .github/workflows/go.yml
echo '---'
cat -n .github/workflows/go.yml | sed -n '1,220p'
echo '--- push/checkout references ---'
rg -n "actions/checkout|persist-credentials|git push|git commit|push back|checkout@" .github/workflows/go.yml .github/workflows -g '*.yml' -g '*.yaml'

Repository: go-vgo/robotgo

Length of output: 2193


Disable checkout credential persistence.
actions/checkout leaves the repo token configured by default, and this workflow has no later git push step that needs it. Set persist-credentials: false on both checkout steps here.

🔒 Suggested hardening
       - name: Check out code into the Go module directory
         uses: actions/checkout@v6
+        with:
+          persist-credentials: false
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- name: Check out code into the Go module directory
uses: actions/checkout@v6
- name: Check out code into the Go module directory
uses: actions/checkout@v6
with:
persist-credentials: false
🧰 Tools
🪛 zizmor (1.26.1)

[warning] 45-46: credential persistence through GitHub Actions artifacts (artipacked): does not set persist-credentials: false

(artipacked)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/go.yml around lines 45 - 46, The checkout steps in this
workflow still persist the repo token by default, which is unnecessary since
there is no later git push use. Update both uses of actions/checkout in the
workflow to set persist-credentials to false, keeping the change tied to the
checkout step configuration so the repository token is not left available after
checkout.

Source: Linters/SAST tools

@vcaesar
vcaesar merged commit c8dbc72 into master Jul 7, 2026
5 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants