docs(examples): checked README sketch and staticcheck in examples-check
- commit
- d2ca9d37403b133b08f6698bc232b2cb18564a5e
- author
- brice · · 2026-10-01 19:23 UTC
- parent
- 53d2224
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
2 files · +17 -7
M Makefile +1 -1
| @@ -21,6 +21,6 @@ fakes-check: | |||
| 21 | 21 | perf-check: | |
| 22 | 22 | CGO_ENABLED=0 go test -run 'TestAlloc' -count=1 ./... | |
| 23 | 23 | examples-check: | |
| 24 | - | cd examples && CGO_ENABLED=0 go build ./... && CGO_ENABLED=0 go vet ./... | |
| 24 | + | cd examples && CGO_ENABLED=0 go build ./... && CGO_ENABLED=0 go vet ./... && CGO_ENABLED=0 staticcheck ./... | |
| 25 | 25 | check: build clean-build vet test fakes-check perf-check | |
| 26 | 26 | CGO_ENABLED=0 staticcheck ./... | |
| @@ -21,6 +21,6 @@ fakes-check: | |||||
| 21 | perf-check: | 21 | perf-check: | ||
| 22 | CGO_ENABLED=0 go test -run 'TestAlloc' -count=1 ./... | 22 | CGO_ENABLED=0 go test -run 'TestAlloc' -count=1 ./... | ||
| 23 | examples-check: | 23 | examples-check: | ||
| 24 | - | cd examples && CGO_ENABLED=0 go build ./... && CGO_ENABLED=0 go vet ./... | 24 | + | cd examples && CGO_ENABLED=0 go build ./... && CGO_ENABLED=0 go vet ./... && CGO_ENABLED=0 staticcheck ./... |
| 25 | check: build clean-build vet test fakes-check perf-check | 25 | check: build clean-build vet test fakes-check perf-check | ||
| 26 | CGO_ENABLED=0 staticcheck ./... | 26 | CGO_ENABLED=0 staticcheck ./... | ||
M README.md +16 -6
| @@ -16,22 +16,32 @@ A Wayland client toolkit library for Go: connection, outputs, surface roles, sea | |||
| 16 | 16 | The library does not render. The `examples` module pairs it with [NeferGUI](https://github.com/bnema/nefergui) (a pure graphics library with no Wayland code); the two never import each other, and the examples copy plain fields between them. The loop runs on one owner goroutine: | |
| 17 | 17 | ||
| 18 | 18 | ```go | |
| 19 | - | conn, _ := neferclient.Connect(ctx, "") | |
| 20 | - | surf, _ := conn.NewLayerSurface(neferclient.LayerConfig{Level: neferclient.LayerTop, Width: 240, Height: 90}) | |
| 19 | + | conn, err := neferclient.Connect(ctx, "") | |
| 20 | + | if err != nil { | |
| 21 | + | return fmt.Errorf("connect: %w", err) | |
| 22 | + | } | |
| 23 | + | defer conn.Close() | |
| 24 | + | surf, err := conn.NewLayerSurface(neferclient.LayerConfig{Level: neferclient.LayerTop, Width: 240, Height: 90}) | |
| 25 | + | if err != nil { | |
| 26 | + | return fmt.Errorf("layer surface: %w", err) | |
| 27 | + | } | |
| 21 | 28 | for { | |
| 22 | 29 | select { | |
| 23 | 30 | case <-conn.Wake(): | |
| 24 | - | conn.Dispatch(handler) // Configure, FeedbackDone, Frame, Pointer, Key, FDReady... | |
| 31 | + | if err := conn.Dispatch(handler); err != nil { // Configure, FeedbackDone, Frame, Pointer, Key, FDReady... | |
| 32 | + | return fmt.Errorf("dispatch: %w", err) | |
| 33 | + | } | |
| 34 | + | case <-ctx.Done(): | |
| 35 | + | return nil | |
| 25 | 36 | } | |
| 26 | - | // render with NeferGUI, then: | |
| 27 | - | // surf.ImportBuffer / surf.ImportTimeline / surf.Present | |
| 37 | + | // render with NeferGUI, then surf.ImportBuffer / surf.ImportTimeline / surf.Present | |
| 28 | 38 | } | |
| 29 | 39 | ``` | |
| 30 | 40 | ||
| 31 | 41 | - [`examples/layer`](examples/layer): a layer surface with a counter button. | |
| 32 | 42 | - [`examples/lock`](examples/lock): a session lock with a masked password field. It is a demo and authenticates nothing; read its header before running it. | |
| 33 | 43 | ||
| 34 | - | Run them against a compositor with `cd examples && go run ./layer`. `make examples-check` builds and vets them; the headless test needs a NeferWL binary: `NEFERCLIENT_HEADLESS=/usr/sbin/neferwl go test ./... -run Headless`. | |
| 44 | + | Run them against a compositor with `cd examples && go run ./layer`. `make examples-check` builds, vets and lints them; the headless test needs a NeferWL binary: `cd examples && NEFERCLIENT_HEADLESS=/usr/sbin/neferwl go test -run Headless ./...`. | |
| 35 | 45 | ||
| 36 | 46 | ## License | |
| 37 | 47 | ||
| @@ -16,22 +16,32 @@ A Wayland client toolkit library for Go: connection, outputs, surface roles, sea | |||||
| 16 | The library does not render. The `examples` module pairs it with [NeferGUI](https://github.com/bnema/nefergui) (a pure graphics library with no Wayland code); the two never import each other, and the examples copy plain fields between them. The loop runs on one owner goroutine: | 16 | The library does not render. The `examples` module pairs it with [NeferGUI](https://github.com/bnema/nefergui) (a pure graphics library with no Wayland code); the two never import each other, and the examples copy plain fields between them. The loop runs on one owner goroutine: | ||
| 17 | 17 | ||||
| 18 | ```go | 18 | ```go | ||
| 19 | - | conn, _ := neferclient.Connect(ctx, "") | 19 | + | conn, err := neferclient.Connect(ctx, "") |
| 20 | - | surf, _ := conn.NewLayerSurface(neferclient.LayerConfig{Level: neferclient.LayerTop, Width: 240, Height: 90}) | 20 | + | if err != nil { |
| 21 | + | return fmt.Errorf("connect: %w", err) | |||
| 22 | + | } | |||
| 23 | + | defer conn.Close() | |||
| 24 | + | surf, err := conn.NewLayerSurface(neferclient.LayerConfig{Level: neferclient.LayerTop, Width: 240, Height: 90}) | |||
| 25 | + | if err != nil { | |||
| 26 | + | return fmt.Errorf("layer surface: %w", err) | |||
| 27 | + | } | |||
| 21 | for { | 28 | for { | ||
| 22 | select { | 29 | select { | ||
| 23 | case <-conn.Wake(): | 30 | case <-conn.Wake(): | ||
| 24 | - | conn.Dispatch(handler) // Configure, FeedbackDone, Frame, Pointer, Key, FDReady... | 31 | + | if err := conn.Dispatch(handler); err != nil { // Configure, FeedbackDone, Frame, Pointer, Key, FDReady... |
| 32 | + | return fmt.Errorf("dispatch: %w", err) | |||
| 33 | + | } | |||
| 34 | + | case <-ctx.Done(): | |||
| 35 | + | return nil | |||
| 25 | } | 36 | } | ||
| 26 | - | // render with NeferGUI, then: | 37 | + | // render with NeferGUI, then surf.ImportBuffer / surf.ImportTimeline / surf.Present |
| 27 | - | // surf.ImportBuffer / surf.ImportTimeline / surf.Present | |||
| 28 | } | 38 | } | ||
| 29 | ``` | 39 | ``` | ||
| 30 | 40 | ||||
| 31 | - [`examples/layer`](examples/layer): a layer surface with a counter button. | 41 | - [`examples/layer`](examples/layer): a layer surface with a counter button. | ||
| 32 | - [`examples/lock`](examples/lock): a session lock with a masked password field. It is a demo and authenticates nothing; read its header before running it. | 42 | - [`examples/lock`](examples/lock): a session lock with a masked password field. It is a demo and authenticates nothing; read its header before running it. | ||
| 33 | 43 | ||||
| 34 | - | Run them against a compositor with `cd examples && go run ./layer`. `make examples-check` builds and vets them; the headless test needs a NeferWL binary: `NEFERCLIENT_HEADLESS=/usr/sbin/neferwl go test ./... -run Headless`. | 44 | + | Run them against a compositor with `cd examples && go run ./layer`. `make examples-check` builds, vets and lints them; the headless test needs a NeferWL binary: `cd examples && NEFERCLIENT_HEADLESS=/usr/sbin/neferwl go test -run Headless ./...`. |
| 35 | 45 | ||||
| 36 | ## License | 46 | ## License | ||
| 37 | 47 | ||||