Show HN: Gotui – 一个现代的 Go 终端仪表盘库
Show HN: Gotui – a modern Go terminal dashboard library

原始链接: https://github.com/metaspartan/gotui

## gotui:现代 Go 终端仪表盘 gotui 是一个完全可定制的、跨平台的终端仪表盘和 Go 语言的组件库,源自 termui 并受到 ratatui 的启发。由 Carsen Klock 开发,它专为 2025 年及以后设计,具有显著的升级,包括 TrueColor 支持、改进的性能和现代终端事件处理。 它提供了一套丰富的组件:仪表盘、各种图表(条形图、饼图、雷达图、树状图、漏斗图、火花线、折线图)、地图,以及新增的线性仪表盘、滚动条和像素级 Logo 渲染器。 性能是关键重点,优化的渲染可实现高达 3000 FPS,并最大限度地减少内存分配。布局选项包括响应式网格和选项卡,以及日历和表格等交互元素。样式高度灵活,支持圆角边框、全 RGB 色彩和丰富的文本解析。 gotui 与 iTerm2 和 Kitty 等流行的终端兼容,并利用原生 tcell 实现核心功能。安装过程简化,使用 Go 的依赖管理 – 无需显式 `go get`。

## Gotui:一个新的Go终端仪表盘库 一个名为 **Gotui** 的新Go库已经发布,它是之前未维护的`termui`的现代分支。由carsenk开发,Gotui旨在提供一个简单的API来构建终端仪表盘和工具,但具有显著的改进。 主要特性包括通过`tcell`支持TrueColor和鼠标,正确的尺寸调整处理,以及各种新的小部件,如图表、仪表和甚至世界地图。还包括圆角和折叠边框等视觉增强,以及经过重新设计的渲染器以提高性能。 开发者正在积极寻求反馈,以完善Gotui以供生产使用。早期评论者建议在README中添加屏幕截图以提高可用性,甚至为每种图表类型提供专门的示例。你可以在GitHub上找到该项目:[github.com/metaspartan](https://github.com/metaspartan)。
相关文章

原文

Go Report Card GoDoc License

gotui is a cross-platform and fully-customizable terminal dashboard and widget library built on top of tcell. It is a modern fork of termui, inspired by ratatui and written purely in Go by Carsen Klock.

Logo

This is a modern fork of termui for 2025, heavily upgraded to support TrueColor, modern terminal events, better performance, and new layouts.

gotui is compatible with Go 1.24+.

  • Backend: Native tcell support for TrueColor (24-bit RGB), mouse events, and resize handling.
  • Gauges: Progress bars and gauges.
  • Charts:
    • BarChart: Stacked and standard bar charts.
    • PieChart: Pie and Donut charts.
    • RadarChart: Spider/Radar charts.
    • TreeMap: Hierarchical data visualization.
    • FunnelChart: Process flow/conversion charts.
    • Sparkline: Mini sparklines.
    • Plot: Line, Scatter, and Braille-mode charts.
  • Maps:
    • World Map: High-resolution world map example using the generic Canvas widget (see _examples/canvas.go).
  • New Widgets:
    • LineGauge: Thin, character-based progress bar with alignment options (Block, Dots, custom runic styles).
    • Scrollbar: Ratatui-compatible scrollbars (Vertical/Horizontal) with mouse and keyboard support.
    • Logo: Pixel-perfect block-style logo renderer.
  • Performance:
    • Optimized Rendering: Buffer uses flat slices for O(1) access, providing 2-3x speedup.
    • Zero Allocations: Drawing loops minimized for high-fps scenes (~3000 FPS potential).
  • Layout:
    • Grid: Responsive grid layout.
    • Tabs: Tabbed navigation.
    • Interactive: Calendar, Tables, Input, TextArea.
  • Styling:
    • Rounded Borders: Optional rounded corners for blocks.
    • Full RGB Color support.
    • Border titles (Top and Bottom) with alignment (Left, Center, Right).
    • Rich styling parser for text.
    • Collapsed Borders: Support for merging adjacent block borders using BorderCollapse.
  • Compatibility: Works with modern terminals (iTerm2, Kitty, Alacritty, Ghostty).

It is not necessary to go get gotui, since Go will automatically manage any imported dependencies for you.

go get github.com/metaspartan/gotui/v4
package main

import (
	"log"

	ui "github.com/metaspartan/gotui/v4"
	"github.com/metaspartan/gotui/v4/widgets"
)

func main() {
	if err := ui.Init(); err != nil {
		log.Fatalf("failed to initialize gotui: %v", err)
	}
	defer ui.Close()

	p := widgets.NewParagraph()
	p.Text = "Hello World!"
	p.SetRect(0, 0, 25, 5)

	ui.Render(p)

	for e := range ui.PollEvents() {
		if e.Type == ui.KeyboardEvent {
			break
		}
	}
}

Run an example with go run _examples/{example}.go or run each example consecutively with make run-examples.

(Submit your projects via a PR)

gotui Author: Carsen Klock - X

termui Author: Zack Guo - Github

MIT

联系我们 contact @ memedata.com