chore: add robotgo go build purego pure go implementation - #781
Conversation
- Update robotgo.go and 13 others Generated with Codg Assisted-by: claude-fable-5 via Codg <codg@atomai.cc>
|
|
📝 WalkthroughWalkthroughBuild constraints were updated to support the ChangesPurego Build Tag Introduction
Estimated code review effort: 3 (Moderate) | ~25 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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
puregoas 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 puregois used. - Document the new
puregotag inREADME.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.
| # 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" ./... | ||
|
|
- 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>
There was a problem hiding this comment.
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
📒 Files selected for processing (10)
.github/workflows/go.ymllang/README.de.mdlang/README.es.mdlang/README.fr.mdlang/README.ja.mdlang/README.ko.mdlang/README.pt.mdlang/README.ru.mdlang/README.zh.mdlang/README.zht.md
✅ Files skipped from review due to trivial changes (2)
- lang/README.pt.md
- lang/README.zh.md
| - 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 |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
sed -n '1,220p' .github/workflows/go.yml | cat -nRepository: 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.
| - name: Check out code into the Go module directory | ||
| uses: actions/checkout@v6 |
There was a problem hiding this comment.
🔒 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.
| - 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
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
puregobuild support as a cgo-free default across macOS, Windows, and Linux.puregocan be combined withx11orlibeito select an alternate pure-Go backend.go testwith-tags purego, including Linux coverage forpurego,x11andpurego,libei(withCGO_ENABLED=0).-tags puregoexamples and clarified tag behavior/default backend selection.