展示 HN:Gova – Go 的声明式 GUI 框架
Show HN: Gova – The declarative GUI framework for Go

原始链接: https://github.com/NV404/gova

## Gova:Go 的原生 GUI 框架 Gova 是一个声明式 GUI 框架,使开发者能够使用单一的 Go 代码库构建适用于 macOS、Windows 和 Linux 的原生桌面应用程序。它优先考虑简洁性,提供类型化组件、响应式状态管理和真正的平台对话框——所有这些都打包成一个静态二进制文件,*无需* JavaScript、浏览器或复杂的 C++ 工具链。 主要特性包括清晰、明确的响应式作用域、原生集成(例如通过 cgo 实现 macOS 警报,其他平台使用 Fyne 作为后备方案)以及具有热重载功能的快速开发周期。组件定义为 Go 结构体,从而促进编写简洁且可预测的代码。 目前版本低于 1.0,API 可能会发生变化,因此建议为生产环境使用固定标签。Gova 构建于 Fyne 之上,但对其进行了抽象,提供了一个稳定的公共 API。它需要 Go 1.26+ 和 C 工具链进行编译。 更多信息和示例请访问 [gova.dev](https://gova.dev)。

Hacker News 新闻 | 过去 | 评论 | 提问 | 展示 | 招聘 | 提交 登录 Show HN: Gova – Go 的声明式 GUI 框架 (github.com/nv404) 6 分,aliezsid 发表于 1 小时前 | 隐藏 | 过去 | 收藏 | 讨论 帮助 考虑申请 YC 2026 夏季项目!申请截止日期为 5 月 4 日。 指南 | 常见问题 | 列表 | API | 安全 | 法律 | 申请 YC | 联系方式 搜索:
相关文章

原文

The declarative GUI framework for Go. Build native desktop apps for macOS, Windows, and Linux from a single Go codebase — typed components, reactive state, real platform dialogs, and one static binary. No JavaScript runtime, no embedded browser, no C++ toolchain to learn.

Go Reference Go Report Card CI License: MIT

Status: pre-1.0. The API will shift before v1.0.0. Pin a tag in production.

package main

import g "github.com/nv404/gova"

type Counter struct{}

func (Counter) Body(s *g.Scope) g.View {
    count := g.State(s, 0)
    return g.VStack(
        g.Text(count.Format("Count: %d")).Font(g.Title),
        g.HStack(
            g.Button("-", func() { count.Set(count.Get() - 1) }),
            g.Button("+", func() { count.Set(count.Get() + 1) }),
        ).Spacing(g.SpaceMD),
    ).Padding(g.SpaceLG)
}

func main() {
    g.Run("Counter", g.Define(func(s *g.Scope) g.View {
        return Counter{}
    }))
}
  • Components as structs. Views are plain Go structs with typed prop fields; defaults are zero values; composition is plain function calls. No magic property wrappers, no string keys, no hook-ordering rules.
  • Explicit reactive scope. State, signals, and effects live on a Scope you can see. No hidden scheduler, no re-render surprises, no Rx, no Redux.
  • Real native integrations where it matters. NSAlert, NSOpenPanel, NSSavePanel, and NSDockTile badge/progress/menu on macOS through cgo. Fyne fallbacks on Windows and Linux — same API everywhere.
  • One static binary. go build produces a single executable. No JavaScript runtime, no embedded browser, no extra assets to bundle.
  • Hot reload that actually reloads. gova dev watches Go files, rebuilds on save, and relaunches — with an opt-in PersistedState so UI state survives the reload.
  • Built on Fyne, but Fyne stays internal. The public API is yours to rely on. We swap out renderer details without breaking your code.
Metric Value Notes
Binary size ~32 MB counter example, default build
Stripped ~23 MB go build -ldflags "-s -w"
Memory idle ~80 MB RSS, counter running
Go version 1.26+ plus a C toolchain for cgo
License MIT no runtime fees

Measured on macOS arm64 with Go 1.26.2. Numbers will vary by platform and feature set.

go get github.com/nv404/gova@latest

Optional CLI for dev / build / run:

go install github.com/nv404/gova/cmd/gova@latest
gova dev ./examples/counter

Prerequisites: Go 1.26+ and a C toolchain (Xcode CLT on macOS, build-essential + libgl1-mesa-dev on Linux, MinGW on Windows).

Full documentation lives at gova.dev (or run npm run dev inside docs-site/ for local browsing). Key sections:

Every example in examples/ is a runnable program:

Example What it shows
counter The minimum viable Gova app
todo State, lists, forms
fancytodo Categories, derived state, richer layout
notes Nav, multi-view, stores
themed Dark/light mode, semantic colors
components Viewable composition, ZStack, Scaffold
dialogs Native dialogs, dock badge / progress / menu, app icon
go run ./examples/dialogs
Feature macOS Windows Linux
Core UI Supported Supported Supported
Hot reload (gova dev) Supported Supported Supported
App icon (runtime) Supported Supported Supported
Native dialogs NSAlert / NSOpenPanel Fyne fallback Fyne fallback
Dock / taskbar NSDockTile Planned Planned

The gova CLI ships alongside the framework.

Command Purpose Notes
gova dev Hot reload Watch .go files, rebuild on save, relaunch the window
gova build Compile Static binary to ./bin/<name>
gova run Execute Build and launch once, no file watching

See CONTRIBUTING.md. Tests are the contract:

Issues, discussions, and PRs all live on GitHub. Security issues? See SECURITY.md.

MIT. Gova is built on Fyne (BSD-3), which ships with the module as an internal dependency.

联系我们 contact @ memedata.com