README example lives in examples/minimal; CI keeps them equal
This commit is contained in:
3 files changed
+37
No files matched your search
@@ -53,6 +53,9 @@ jobs:
|
|||||||
- name: Race
|
- name: Race
|
||||||
if: runner.os != 'Windows'
|
if: runner.os != 'Windows'
|
||||||
run: go test -race ${{ matrix.skip }} ./...
|
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
|
- name: Examples compile
|
||||||
run: go build ./examples/...
|
run: go build ./examples/...
|
||||||
- name: Upload snapshot diffs
|
- name: Upload snapshot diffs
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ go mod edit -require=mujicaui@v0.0.0 -replace=mujicaui=/path/to/MujicaUI
|
|||||||
|
|
||||||
## 最小示例
|
## 最小示例
|
||||||
|
|
||||||
|
即 `examples/minimal/main.go`,CI 校验两者一致。
|
||||||
|
|
||||||
```go
|
```go
|
||||||
package main
|
package main
|
||||||
|
|
||||||
|
|||||||
@@ -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)
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user