termui golang version of the terminal dashboard

termui is built on termbox-go is a completely customizable dashboard terminals and cross-platform widget library, inspired by the blessed-contrib and tui-rs

Support features

  • Prefabricated widget several common use cases
  • Easily create custom widgets
  • Member positioned at the opposite small absolute coordinates or grid
  • Keyboard, mouse, and resize events terminals
  • Color and style

Simple to use

go mod

  • Create a project
go mod init github.com/rongfengliang/dashapp
go get github.com/gizak/termui/v3
main.go:
package main
import (
 "log"
 ui "github.com/gizak/termui/v3"
 "github.com/gizak/termui/v3/widgets"
)
func main() {
 if err := ui.Init(); err != nil {
  log.Fatalf("failed to initialize termui: %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
  }
 }
}
  • running result
go run main.go
 

 

 

Explanation

Similar golang package is a lot of, can easily be used to develop cli dashboard application

Reference material

https://github.com/gizak/termui

Guess you like

Origin www.cnblogs.com/rongfengliang/p/12418522.html