README example lives in examples/minimal; CI keeps them equal

This commit is contained in:
ZacharyZhang-NY committed 2026-10-05 13:20:41 -04:00
1 parent b8242d4e28
commit 824154f163
3 files changed
+37

No files matched your search

+3
View File
@@ -53,6 +53,9 @@ jobs:
- name: Race
if: runner.os != 'Windows'
run: go test -race ${{ matrix.skip }} ./...
- name: README example matches examples/minimal
if: runner.os == 'Linux'
run: diff <(awk '/^```go$/{f=1;n++;next} /^```$/{f=0} f && n==1' README.md) examples/minimal/main.go
- name: Examples compile
run: go build ./examples/...
- name: Upload snapshot diffs
+2
View File
@@ -16,6 +16,8 @@ go mod edit -require=mujicaui@v0.0.0 -replace=mujicaui=/path/to/MujicaUI
## 最小示例
即 `examples/minimal/main.go`,CI 校验两者一致。
```go
package main
+32
View File
@@ -0,0 +1,32 @@
package main
import (
"log"
"github.com/egoist/mygo"
"github.com/egoist/mygo/ui"
mujica "mujicaui"
)
type app struct{ name string }
func (a *app) view(c *ui.Context) {
mujica.Use(c, mujica.Settings{Locale: mujica.ZhCN})
ui.Column(c).Fill().Center().Gap(12).Children(func() {
mujica.TextInput(c, &a.name, mujica.TextInputOptions{Placeholder: "姓名"})
if mujica.Button(c, "觐见", mujica.ButtonOptions{}).Clicked() {
log.Println("hello", a.name)
}
})
}
func main() {
a := &app{}
mygo.App.WhenReady(func() {
mygo.NewWindow(mygo.WindowOptions{Title: "Mujica", Width: 480, Height: 320, Content: ui.View(a.view)})
})
if err := mygo.App.Run(); err != nil {
log.Fatal(err)
}
}