fix(hotkey): split platform files by platform+cgo build matrix
The `!darwin` guard on the modifier helpers was too broad: golang.design/x/ hotkey only exposes its Mod*/Key* constants from the darwin&&cgo, linux&&cgo and windows backends, while the `!windows && !cgo` complement (e.g. Linux cross-builds with CGO_ENABLED=0) falls back to a stub with no constants. That made hk.ModCtrl/ModShift/KeyA... undefined and produced editor/vet warnings. Realign the build tags with the upstream matrix and confine every hk.* constant to a tagged file so the shared hotkey.go compiles everywhere. Also fix the Linux mapping (option -> hk.Mod1; hk.ModAlt does not exist on X11).
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
//go:build !windows && !cgo
|
||||
|
||||
package hotkey
|
||||
|
||||
import hk "golang.design/x/hotkey"
|
||||
|
||||
// This file covers the configuration where golang.design/x/hotkey compiles its
|
||||
// cgo-less stub (any non-Windows platform built with CGO_ENABLED=0). In that
|
||||
// stub the package defines the Modifier/Key types but no Mod*/Key* constants,
|
||||
// and Register panics at runtime. We still provide the package-internal
|
||||
// helpers so that snapgo keeps cross-compiling (e.g. `go vet`, editor analysis,
|
||||
// or CI cross-builds) without pulling in a C toolchain.
|
||||
//
|
||||
// The returned values are inert zero modifiers and lookupKey always reports
|
||||
// "unsupported": callers on this build cannot register a real global hotkey,
|
||||
// so surfacing an "unsupported token" parse error is preferable to reaching
|
||||
// the upstream panic.
|
||||
func modCmd() hk.Modifier { return 0 }
|
||||
func modCtrl() hk.Modifier { return 0 }
|
||||
func modOption() hk.Modifier { return 0 }
|
||||
func modShift() hk.Modifier { return 0 }
|
||||
|
||||
// lookupKey has no key constants to map against in the cgo-less stub, so it
|
||||
// always reports the token as unsupported.
|
||||
func lookupKey(string) (hk.Key, bool) { return 0, false }
|
||||
Reference in New Issue
Block a user