nsgo

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 16, 2026 License: Apache-2.0 Imports: 4 Imported by: 4

README

NSGo

NSGo

English | 简体中文

GitHub Blog X Telegram GitHub Sponsors

A cross-platform native UI engine with a Go backend: app logic, the reactive graph and layout run in Go, and each platform draws with its own native UI.
It follows the design of Native Shell (NSH), for teams that want NSH's model without writing Rust.

The gallery's Stocks demo on macOS The gallery's component list on a phone

Status

NSGo is early: 0.1.0 is its first release, and its API is not stable yet. It runs on macOS, iOS and its App Clips, tvOS, watchOS, Windows, Linux, the web, Android, and experimentally in WeChat, QQ, Alipay and Douyin mini programs, which hold an app to 2 MB, and apps embed in iOS, Android and Go desktop apps of their own; ARCHITECTURE.md tracks each target.

Getting started

With Go 1.27.3 or later, and Xcode for iOS, tvOS and watchOS, create an app and run it with hot reload:

go mod init example.com/hello
go get github.com/nsgo-dev/nsgo
go get -tool github.com/nsgo-dev/nsgo/cmd/nsgo
go tool nsgo init   # -template tsx for a TSX app
go tool nsgo dev    # -target web, ios_simulator, tvos_simulator, watchos_simulator, android or miniprogram_wechat to run elsewhere

An app is Go components that return elements, with signals updating what reads them:

func Root(cx *core.Scope) core.Node {
	count := core.NewSignal(cx, 0)
	return core.View{Style: core.Style{Padding: core.All(24), Gap: 12}, Children: []core.Node{
		core.Text{ContentFunc: func() string { return fmt.Sprintf("Pressed %d times", count.Get()) }},
		base.Button{
			OnPress:  func(core.PressEvent) { count.Update(func(n int) int { return n + 1 }) },
			Children: []core.Node{core.Text{Content: "Press me"}},
		},
	}}
}

func main() { nsgo.Run(Root) }

Documentation

The docs cover components and state, layout, styles, navigation, a component reference, TSX apps, localization, testing, embedding, building and shipping; the live demo runs the gallery in the browser.

Coding agents learn NSGo from its skill, bunx skills add nsgo-dev/nsgo, and read the docs as Markdown from llms.txt.

Development

go tool nsgo dev examples/gallery   # run the gallery
go tool nsgo check                  # vet every package
go tool nsgo test                   # every package's tests

Contributing has the rest of the setup. Read ARCHITECTURE.md and AGENTS.md before changing code, and CHANGELOG.md for what changed.

Community

Questions, ideas and what you build with NSGo are welcome in nsgo-dev-community, the Telegram group @nsgo_dev. Report bugs and propose changes in issues.

License

Licensed under the Apache License, Version 2.0. NSGo is a port of NSH, and NOTICE records the attribution that port owes.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in NSGo by you, as defined in the Apache-2.0 license, shall be licensed under Apache-2.0, without any additional terms or conditions.

Documentation

Overview

Package nsgo runs an NSGo app on the platform it is built for, either a root view, which shows in the app's main window:

func main() { nsgo.Run(Root) }

or the app's function, which opens its windows, panels and tray icons itself (package desktop), as an Avalonia application does:

func main() { nsgo.Run(App) }

func App(app *core.Scope) {
	desktop.SetShutdownMode(app, desktop.ShutdownOnExplicit)
	desktop.NewTray(app, desktop.TrayOptions{Icon: icon, Panel: desktop.OpenPanel(app, desktop.PanelOptions{}, Panel)})
}

Build tags pick the backend. The nsgo tool builds the app's identity into it (core.App), and its updates where nsgo.yaml configures them (package updater), from nsgo.yaml. The engine's own command-line flags, such as --nsgo-fps, leave os.Args before main runs (launchFlags).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run[M Main](main M, opts ...Option)

Run runs main and the platform's event loop. Call it from main.

A root view shows in the app's main window, or fills the app on phones and the web. The app's function runs once, in the app's own scope, and opens what the app shows: on macOS, Windows and Linux its windows, panels and tray icons (package desktop); everywhere the view SetMainView sets. Where the platform opens no windows of the app's (phones and the web, Windows when Run is given a root view, and Linux when it is given a root view and no automatic update checks) desktop.OpenWindow returns nil.

On desktops Run returns once the app ends, by its shutdown mode (desktop.SetShutdownMode), core.Scope.Quit or desktop.Restart, its storage written, so main can clean up; on iOS, Android and the web it never returns. After desktop.Restart it has started the app again, which waits for this process to exit.

func SetMainView

func SetMainView(cx *core.Scope, view func(cx *core.Scope) core.Node)

SetMainView shows view as the app's main view: in its main window on desktops, which it opens, else filling the app. A later call replaces the view.

Types

type App

type App = engine.App

App builds an app's root element once.

type Main

type Main interface {
	func(cx *core.Scope) core.Node | func(app *core.Scope)
}

Main is what Run runs: a root view, or the app's function.

type Option

type Option func(*options)

Option configures Run and NewView.

func Appearance

func Appearance(appearance core.Appearance) Option

Appearance starts the app in appearance whatever the system's, its window and native chrome included, as core.Scope.SetAppearance later changes it.

func Component

func Component(name string, factory core.NativeFactory) Option

Component registers a native component the app's Native elements name: factory makes the platform view for each one. Register the components of each platform in files built for it.

func DataDir

func DataDir(dir string) Option

DataDir keeps a view's app data, its storage included, in dir rather than in the system's directory for the app's ID.

func Fonts

func Fonts(paths ...string) Option

Fonts registers the font files at paths, slash-separated under the app's resources directory (TrueType, OpenType or collections), before the first view: text names them by their families, as Font.Family or a Style's FontFamily.

func HideDock

func HideDock() Option

HideDock starts the app out of the Dock and the app switcher, on macOS, as a tray or background app runs: set before the app starts, its icon never shows there. desktop.SetDockVisible changes it later.

func HostChannel

func HostChannel(h *core.Host) Option

HostChannel has a view use h as its channel to the host, made before it, rather than a new one.

func OnError

func OnError(fn func(error)) Option

OnError has fn hear each failure a view's app does not catch with a core.Catch, on the app's goroutine; it must not block.

func Parent

func Parent(handle uintptr) Option

Parent is the window NewView's view is made in: on Windows, where a view is a child window, the HWND of the host's window, which it needs. Other platforms ignore it.

func WindowConstraints

func WindowConstraints(c core.WindowConstraints) Option

WindowConstraints limits the main window's content size and what the user may do to it: desktop.SetWindowConstraints says how, and changes them later. desktop.OpenWindow's windows take their own from WindowOptions.

func WindowFrame

func WindowFrame(f core.WindowFrame) Option

WindowFrame opens the main window with frame f, as desktop.Frame reported it, instead of centered at WindowSize: an app restores its window with it. A window no screen would show, as on a screen that went away, opens centered on the main screen. Linux takes only the size.

func WindowMaterial

func WindowMaterial(material core.WindowMaterial) Option

WindowMaterial starts the main window with material behind its content, where the app draws nothing opaque: a system vibrancy material on macOS and a system backdrop on Windows 11 22H2 or later. Other targets ignore it. desktop.SetWindowMaterial changes it later, which on Windows needs a window started with one.

func WindowSize

func WindowSize(width, height core.Points) Option

WindowSize sizes the main window's content, in points: 480 by 640 by default. desktop.OpenWindow's windows take it where they set no size.

type View

type View struct {
	// contains filtered or unexported fields
}

View is an app in a native view of a host app's own window, run by the host's own event loop: an NSView on macOS, a GtkWidget on Linux, a child window on Windows. Go desktop apps embed NSGo apps with it; iOS and Android apps embed them with the frameworks `nsgo build -embed` makes. Each View is an engine of its own, so a process shows as many as it likes, in one window or several. Call its methods on the platform's main thread.

func NewView

func NewView(app App, opts ...Option) *View

NewView makes a view showing app, for a host that runs the platform's event loop itself. The host puts Handle in its window and sizes it; the app starts once it is there, so settings made before are in its first frame. Component, Fonts, Appearance, Parent, DataDir, OnError and HostChannel apply; WindowMaterial, WindowSize and HideDock are Run's, as are the engine's command-line flags (--nsgo-fps). Close the view when the host is done with it.

func (*View) Close

func (v *View) Close()

Close stops the app, writing its storage, and destroys its native components and the view.

func (*View) Handle

func (v *View) Handle() uintptr

Handle returns the native view: an NSView pointer on macOS, a GtkWidget pointer on Linux, the child window's HWND on Windows.

func (*View) Host

func (v *View) Host() *core.Host

Host returns the channel between the host and the app: the app's launch parameters, the events the host sends it and the functions it calls (core.Scope.CallHost), and the host's URL handler.

func (*View) SetAppearance

func (v *View) SetAppearance(a core.Appearance)

SetAppearance shows the app light or dark in place of the system's appearance, the platform's own chrome in the view too; core.AppearanceSystem follows the system again. An appearance the app forces still wins.

func (*View) SetFontScale

func (v *View) SetFontScale(scale float32)

SetFontScale sets the text size multiplier in place of the system's; 0 follows the system again.

func (*View) SetLocale

func (v *View) SetLocale(locale string)

SetLocale has the app format for locale, a BCP 47 tag such as "de-CH", in place of the system's language; "" follows the system again. The layout direction stays the system's.

func (*View) SetTokens

func (v *View) SetTokens(t core.Tokens)

SetTokens gives the app the values the host themes it with, which it reads with core.Env.Token.

Directories

Path Synopsis
Package audio plays sound: a Sound, a short sound decoded once and played any number of times, overlapping, and a Player of long audio, streamed and decoded as it plays, as NSH's Sound and AudioPlayer.
Package audio plays sound: a Sound, a short sound decoded once and played any number of times, overlapping, and a Player of long audio, streamed and decoded as it plays, as NSH's Sound and AudioPlayer.
Package base holds NSGo's built-in unstyled components: controls, disclosure, progress, popups, menus, dialogs, sheets, navigation, safe areas, resizable panels, a dock and the keyboard.
Package base holds NSGo's built-in unstyled components: controls, disclosure, progress, popups, menus, dialogs, sheets, navigation, safe areas, resizable panels, a dock and the keyboard.
camera
Package camera is a plane the user pans and zooms, such as a design canvas or a board of diagrams: the app lays its content out at its own size on the plane, and the view shows it through a camera that moves and scales it on the platform's frame clock.
Package camera is a plane the user pans and zooms, such as a design canvas or a board of diagrams: the app lays its content out at its own size on the plane, and the view shows it through a camera that moves and scales it on the platform's frame clock.
commitgraph
Package commitgraph lays out and draws a Git history's revision graph: the lanes commits sit in and the lines joining them to their parents.
Package commitgraph lays out and draws a Git history's revision graph: the lanes commits sit in and the lines joining them to their parents.
diagram
Package diagram draws Mermaid diagrams natively, with limu (github.com/firede/limu), which reads every diagram type Pele, the Obsidian team's Mermaid renderer, draws and lays it out: flowcharts, sequence, class, state and entity relationship diagrams, Gantt charts, pies, mind maps, timelines and more.
Package diagram draws Mermaid diagrams natively, with limu (github.com/firede/limu), which reads every diagram type Pele, the Obsidian team's Mermaid renderer, draws and lays it out: flowcharts, sequence, class, state and entity relationship diagrams, Gantt charts, pies, mind maps, timelines and more.
diagram/locales
Package locales says what base/diagram's diagrams read as, to assistive technology, in the language the app shows.
Package locales says what base/diagram's diagrams read as, to assistive technology, in the language the app shows.
diff
Package diff is base's DiffView, a port of NSH's: the changes between two texts, or the files of a patch, side by side or one over the other, the words changed within lines marked, the unchanged lines between changes collapsed into separators that expand, and the text colored by the Editor's highlighting.
Package diff is base's DiffView, a port of NSH's: the changes between two texts, or the files of a patch, side by side or one over the other, the words changed within lines marked, the unchanged lines between changes collapsed into separators that expand, and the text colored by the Editor's highlighting.
editor
Package editor is base's code editor, a port of NSH's Editor (and GPUI Kit's): syntax highlighting, line numbers, several carets, folding, soft wrap, find and replace, diagnostics and decorations, completion and go to definition, with the keys of code editors.
Package editor is base's code editor, a port of NSH's Editor (and GPUI Kit's): syntax highlighting, line numbers, several carets, folding, soft wrap, find and replace, diagnostics and decorations, completion and go to definition, with the keys of code editors.
flow
Package flow draws a directed diagram, such as a workflow, a dependency graph or a plan of tasks, and lays it out automatically: nodes fall into ranks along the edges' direction, ranks are ordered to avoid crossings and edges run between them as orthogonal lines.
Package flow draws a directed diagram, such as a workflow, a dependency graph or a plan of tasks, and lays it out automatically: nodes fall into ranks along the edges' direction, ranks are ordered to avoid crossings and edges run between them as orthogonal lines.
formula
Package formula typesets math, written in TeX or Typst, with Untie (github.com/caelyreth/untie), and draws it as shapes in the font size and the text color it inherits: inline, on its text's baseline, or as a display formula of its own.
Package formula typesets math, written in TeX or Typst, with Untie (github.com/caelyreth/untie), and draws it as shapes in the font size and the text color it inherits: inline, on its text's baseline, or as a display formula of its own.
formula/locales
Package locales says what base/formula's formulas read as, to assistive technology, in the language the app shows.
Package locales says what base/formula's formulas read as, to assistive technology, in the language the app shows.
internal/parts
Package parts is what base's components share to style their parts.
Package parts is what base's components share to style their parts.
internal/sheet
Package sheet is the sheet base's dialogs, menus and docks come up as: a panel from an edge of the window over a fading backdrop.
Package sheet is the sheet base's dialogs, menus and docks come up as: a panel from an edge of the window over a fading backdrop.
internal/syntax
Package syntax is what code highlighting in base shares: the kinds of tokens, chroma's token types mapped onto them and NSH's palette, Allsum's, in light and dark.
Package syntax is what code highlighting in base shares: the kinds of tokens, chroma's token types mapped onto them and NSH's palette, Allsum's, in light and dark.
internal/window
Package window is the rows a virtualized view of base makes: a table's, an editor's.
Package window is the rows a virtualized view of base makes: a table's, an editor's.
locales
Package locales says base's own messages in the language the app shows.
Package locales says base's own messages in the language the app shows.
richeditor
Package richeditor is a rich text editor after ProseMirror's architecture (NSH's RichEditor, nsh/docs/dev/rich-editor.md): a document whose structure a Schema defines, changes as invertible, mappable steps grouped into transactions, immutable states, commands and plugins.
Package richeditor is a rich text editor after ProseMirror's architecture (NSH's RichEditor, nsh/docs/dev/rich-editor.md): a document whose structure a Schema defines, changes as invertible, mappable steps grouped into transactions, immutable states, commands and plugins.
terminal
Package terminal is a terminal for NSGo apps: a View that runs the user's shell, or any program, in a pseudo-terminal, with Ghostty's terminal emulator, libghostty-vt, loaded at run time with no cgo.
Package terminal is a terminal for NSGo apps: a View that runs the user's shell, or any program, in a pseudo-terminal, with Ghostty's terminal emulator, libghostty-vt, loaded at run time with no cgo.
terminal/internal/library
Package library finds libghostty-vt for the terminal: the file $NSGO_GHOSTTY_VT names, the one the nsgo tool put into the app, or on desktops the build for the platform the package embeds, written once into the user's cache.
Package library finds libghostty-vt for the terminal: the file $NSGO_GHOSTTY_VT names, the one the nsgo tool put into the app, or on desktops the build for the platform the package embeds, written once into the user's cache.
terminal/internal/pty
Package pty runs processes in pseudo-terminals, in pure Go: /dev/ptmx on macOS and Linux, ConPTY on Windows.
Package pty runs processes in pseudo-terminals, in pure Go: /dev/ptmx on macOS and Linux, ConPTY on Windows.
terminal/internal/vt
Package vt binds libghostty-vt, the terminal emulator of Ghostty, which it loads at run time through purego: no cgo.
Package vt binds libghostty-vt, the terminal emulator of Ghostty, which it loads at run time through purego: no cgo.
terminal/locales
Package locales says the terminal's own messages in the language the app shows.
Package locales says the terminal's own messages in the language the app shows.
textview
Package textview shows a document of Markdown or the app's own blocks with the primitives: texts with spans, views, scroll views and images.
Package textview shows a document of Markdown or the app's own blocks with the primitives: texts with spans, views, scroll views and images.
textview/highlight
Package highlight colors the code blocks of a TextView with chroma's lexers and NSH's reading palette, light and dark.
Package highlight colors the code blocks of a TextView with chroma's lexers and NSH's reading palette, light and dark.
textview/locales
Package locales says the text view's own messages in the language the app shows.
Package locales says the text view's own messages in the language the app shows.
cmd
nsgo command
Command nsgo develops and builds NSGo apps.
Command nsgo develops and builds NSGo apps.
nsgo/apk
Package apk writes Android packages: the ZIP archive, the binary manifest and the v2 signature.
Package apk writes Android packages: the ZIP archive, the binary manifest and the v2 signature.
Package core is what NSGo apps are written with: elements, styles, the reactive graph and regions, the services an app asks for, and the shadow tree that turns them into mount items, laid out and with text prepared.
Package core is what NSGo apps are written with: elements, styles, the reactive graph and regions, the services an app asks for, and the shadow tree that turns them into mount items, laid out and with text prepared.
Package desktop holds what only desktops have: the window, its title bar and the menus, as NSH's nsh/desktop.
Package desktop holds what only desktops have: the window, its title bar and the menus, as NSH's nsh/desktop.
locales
Package locales says the words of the platforms' menus and of macOS's permission guide, which the backends show in the language the app shows: the standard items', the menus apps build around them, and the guide's panel with the titles of System Settings' privacy panes.
Package locales says the words of the platforms' menus and of macOS's permission guide, which the backends show in the language the app shows: the standard items', the menus apps build around them, and the guide's panel with the titles of System Settings' privacy panes.
examples
appclip command
Command appclip is a café's app with an App Clip: the app, here, keeps the user's orders, and the clip, in package clip, orders at a table from the link its code opens, without installing the app.
Command appclip is a café's app with an App Clip: the app, here, keeps the user's orders, and the clip, in package clip, orders at a table from the link its code opens, without installing the app.
appclip/clip command
Command clip is the App Clip of the café's app: a table's code opens https://cafe.example.com/table?n=12, and the clip orders to that table.
Command clip is the App Clip of the café's app: a table's code opens https://cafe.example.com/table?n=12, and the clip orders to that table.
embed-desktop command
Command embed-desktop is a desktop app of its own that embeds NSGo: its window, built with the platform's toolkit and run by its own event loop, shows a status line, a button and two NSGo views of examples/embedded/app side by side, each an engine of its own.
Command embed-desktop is a desktop app of its own that embeds NSGo: its window, built with the platform's toolkit and run by its own event loop, shows a status line, a button and two NSGo views of examples/embedded/app side by side, each an engine of its own.
embedded command
Command embedded builds the embeddable app in app for iOS and Android hosts: `nsgo build -embed -target ios` makes the framework examples/embed-ios links, and `-target android` the library examples/embed-android adds.
Command embedded builds the embeddable app in app for iOS and Android hosts: `nsgo build -embed -target ios` makes the framework examples/embed-ios links, and `-target android` the library examples/embed-android adds.
embedded/app
Package app is an NSGo app made to be embedded: it greets the user its host names in its launch parameters, shows the host's messages, calls and posts to the host, shows the host's own badge as a native component, opens a link the host routes, and themes itself with the host's tokens, locale and text size.
Package app is an NSGo app made to be embedded: it greets the user its host names in its launch parameters, shows the host's messages, calls and posts to the host, shows the host's own badge as a native component, opens a link the host routes, and themes itself with the host's tokens, locale and text size.
gallery command
Command gallery shows what NSGo apps are made of: core's elements and services, and the components of base and ui, in NSH's gallery's design, under two tabs.
Command gallery shows what NSGo apps are made of: core's elements and services, and the components of base and ui, in NSH's gallery's design, under two tabs.
gallery-tsx command
Command gallery-tsx is the gallery's Components written in TSX: a page per family of components, on nsgo/ui and nsgo/base, with knobs that set their props.
Command gallery-tsx is the gallery's Components written in TSX: a page per family of components, on nsgo/ui and nsgo/base, with knobs that set their props.
gallery/locales
Package locales says the gallery's own messages, its settings' among them, in the language it shows.
Package locales says the gallery's own messages, its settings' among them, in the language it shows.
hello command
Command hello is the smallest app worth packaging: it greets the name typed into it and counts its greetings, in English and Chinese, and its App Clip (clip) greets the name a link gives.
Command hello is the smallest app worth packaging: it greets the name typed into it and counts its greetings, in English and Chinese, and its App Clip (clip) greets the name a link gives.
hello/clip command
Command clip is the hello example's App Clip: a link such as https://hello.example.com/?name=Ada opens it, and it greets the name the link gives, in the app's languages.
Command clip is the hello example's App Clip: a link such as https://hello.example.com/?name=Ada opens it, and it greets the name the link gives, in the app's languages.
hello/locales
Package locales says the hello example's messages in the language it shows.
Package locales says the hello example's messages in the language it shows.
orbit command
Command orbit shows six live native views standing on one ring in perspective, over a calibrated dial a WGSL shader draws on the floor.
Command orbit shows six live native views standing on one ring in perspective, over a calibrated dial a WGSL shader draws on the floor.
plugins command
Command plugins is a Go app that installs and runs signed TSX packages: it verifies greeter.nsgopkg against the root key rootKey, off the engine's goroutine, asks the user to grant what its capabilities declare, installs it in the app's data directory and shows it in tsx.View, which reaches the app only through a host channel of its own; or it shows why the package was refused.
Command plugins is a Go app that installs and runs signed TSX packages: it verifies greeter.nsgopkg against the root key rootKey, off the engine's goroutine, asks the user to grant what its capabilities declare, installs it in the app's data directory and shows it in tsx.View, which reaches the app only through a host channel of its own; or it shows why the package was refused.
previews command
Command previews shows the docs' component examples live: each demo is the code of a block in docs/public/*/ui/, with what the block leaves out defined around it.
Command previews shows the docs' component examples live: each demo is the code of a block in docs/public/*/ui/, with what the block leaves out defined around it.
tray command
Command tray is a menu bar app run as an Avalonia application runs: nsgo.Run starts the app's function, which opens what it shows.
Command tray is a menu bar app run as an Avalonia application runs: nsgo.Run starts the app's function, which opens what it shows.
tsx command
Command tsx is an app written in TSX and styled with Tailwind CSS classes: today's tasks and a focus timer.
Command tsx is an app written in TSX and styled with Tailwind CSS classes: today's tasks and a focus timer.
widgets command
Command widgets is a counter whose widgets show its count: on the Mac's desktop and in Notification Center, and on the Home Screen and the Lock Screen of an iPhone or an iPad.
Command widgets is a counter whose widgets show its count: on the Mac's desktop and in Notification Center, and on the Home Screen and the Lock Screen of an iPhone or an iPad.
Package i18n says an app's messages in the language it shows: what the code nsgo writes from a package's catalogs (locales/*.yaml) runs on.
Package i18n says an app's messages in the language it shows: what the code nsgo writes from a package's catalogs (locales/*.yaml) runs on.
icons
internal
audiosession
Package audiosession holds iOS's one AVAudioSession for every part of NSGo that sets it: videos, the audio package's players and sounds, speech and microphone.
Package audiosession holds iOS's one AVAudioSession for every part of NSGo that sets it: videos, the audio package's players and sounds, speech and microphone.
automation
Package automation is the protocol between the nsgo tool and an app `nsgo dev -automation` built: the tool sends a Request and the app's agent (package nsgotest) answers it.
Package automation is the protocol between the nsgo tool and an app `nsgo dev -automation` built: the tool sends a Request and the app's agent (package nsgotest) answers it.
backend
Package backend runs an app on the platform it is built for, which build tags pick (run_*.go, view_*.go): what nsgo.Run and nsgo.NewView do once they have gathered their options.
Package backend runs an app on the platform it is built for, which build tags pick (run_*.go, view_*.go): what nsgo.Run and nsgo.NewView do once they have gathered their options.
cldr
Package cldr formats dates and times by the Unicode CLDR's data, as ICU and Intl write them, and transforms messages for the pseudo locales, for package i18n.
Package cldr formats dates and times by the Unicode CLDR's data, as ICU and Intl write them, and transforms messages for the pseudo locales, for package i18n.
cldr/internal/gen command
Command gen writes tables.go, the data of the Unicode CLDR package cldr formats dates with, from a pinned release of cldr-json: go generate ./internal/cldr runs it.
Command gen writes tables.go, the data of the Unicode CLDR package cldr formats dates with, from a pinned release of cldr-json: go generate ./internal/cldr runs it.
dev
devtools
Package devtools is what nsgo dev -devtools and -automation read from a running app and send it: core registers each surface's tree here while Enabled, and nsgo's dev client serves them to the DevTools page and hands them to the automation's Agent, over one channel.
Package devtools is what nsgo dev -devtools and -automation read from a running app and send it: core registers each surface's tree here while Enabled, and nsgo's dev client serves them to the DevTools page and hands them to the automation's Agent, over one channel.
driver
Package driver is the protocol between core and the platform backends: the mount items a commit sends, the events backends report, the TextEngine they implement, and the values both sides share.
Package driver is the protocol between core and the platform backends: the mount items a commit sends, the events backends report, the TextEngine they implement, and the values both sides share.
engine
Package engine runs an app on a goroutine of its own and hands the platform one MountBatch per commit.
Package engine runs an app on a goroutine of its own and hands the platform one MountBatch per commit.
layout
Package layout is NSGo's layout engine: a Go reimplementation of the CSS layout algorithms of Taffy 0.15 with the features NSH enables (block, flexbox, grid and content sizes; no floats, no calc(), no balanced flex wrapping).
Package layout is NSGo's layout engine: a Go reimplementation of the CSS layout algorithms of Taffy 0.15 with the features NSH enables (block, flexbox, grid and content sizes; no floats, no calc(), no balanced flex wrapping).
moduletest
Package moduletest holds the tests that check the whole module rather than one package: its import layers (layering_test.go), what apps link (linked_test.go), the public API's types (api_test.go), that base reads no theme (theme_test.go) and the skills it gives coding agents (skills_test.go).
Package moduletest holds the tests that check the whole module rather than one package: its import layers (layering_test.go), what apps link (linked_test.go), the public API's types (api_test.go), that base reads no theme (theme_test.go) and the skills it gives coding agents (skills_test.go).
platform/android/runtime
Package runtime holds the prebuilt parts of every APK: the Java runtime in ../java, compiled to dex, and the manifest nsgo build fills in for each app; and the same runtime as a jar, for the libraries nsgo build -embed makes.
Package runtime holds the prebuilt parts of every APK: the Java runtime in ../java, compiled to dex, and the manifest nsgo build fills in for each app; and the same runtime as a jar, for the libraries nsgo build -embed makes.
platform/apple
Package apple holds what the AppKit and UIKit backends share, called through purego without cgo: CoreFoundation strings, CoreGraphics colors and canvases, layer styles and transitions, the CoreText text engine, which prepares and lays text out on the engine goroutine for the main thread to draw, and image views, which load and decode off it.
Package apple holds what the AppKit and UIKit backends share, called through purego without cgo: CoreFoundation strings, CoreGraphics colors and canvases, layer styles and transitions, the CoreText text engine, which prepares and lays text out on the engine goroutine for the main thread to draw, and image views, which load and decode off it.
platform/canvas2d
Package canvas2d plays NSGo's drawings into a canvas's 2D context over syscall/js: a browser's <canvas> on the web, and a WeChat mini program's offscreen canvas, which has the same context.
Package canvas2d plays NSGo's drawings into a canvas's 2D context over syscall/js: a browser's <canvas> on the web, and a WeChat mini program's offscreen canvas, which has the same context.
platform/canvastest
Package canvastest holds drawings that exercise a canvas player, and what their pixels must show, so each backend's tests check their player the same way: they draw each Sample on white at twice its points and run its probes.
Package canvastest holds drawings that exercise a canvas player, and what their pixels must show, so each backend's tests check their player the same way: they draw each Sample on white at twice its points and run its probes.
platform/field
Package field keeps what a backend reports about one text field the way NSH's platforms do, whatever control edits it: the user's edits and their count, a composition and the value the app sets during one, the selection, keys and maxLength.
Package field keeps what a backend reports about one text field the way NSH's platforms do, whatever control edits it: the user's edits and their count, a composition and the value the app sets during one, the selection, keys and maxLength.
platform/finger
Package finger reports a mouse as finger 0 of core.EventTouch, for the desktop backends: its primary button going down, moving while down and going up are a finger's touches.
Package finger reports a mouse as finger 0 of core.EventTouch, for the desktop backends: its primary button going down, moving while down and going up are a finger's touches.
platform/fontfile
Package fontfile reads what the backends need to register an app's font files: the family, weight and slant of each face in a TrueType, OpenType or collection file, from its name and OS/2 tables.
Package fontfile reads what the backends need to register an app's font files: the family, weight and slant of each face in a TrueType, OpenType or collection file, from its name and OS/2 tables.
platform/hover
Package hover follows the pointer over views for the backends whose views hear no hovers of their own, Windows' and Linux's.
Package hover follows the pointer over views for the backends whose views hear no hovers of their own, Windows' and Linux's.
platform/imagedecode
Package imagedecode decodes image bytes into premultiplied pixels for the backends that decode images themselves: PNG, JPEG, GIF and WebP, animated GIF and WebP with every frame composited, and SVG drawn by a rasterizer of its own from core.ParseSVG's drawing, as NSH's svg module draws with resvg.
Package imagedecode decodes image bytes into premultiplied pixels for the backends that decode images themselves: PNG, JPEG, GIF and WebP, animated GIF and WebP with every frame composited, and SVG drawn by a rasterizer of its own from core.ParseSVG's drawing, as NSH's svg module draws with resvg.
platform/imageload
Package imageload fetches image bytes for the native backends: https and http, file paths and file: URIs, data: URIs, "asset:" paths under the app's resources and bytes the app holds.
Package imageload fetches image bytes for the native backends: https and http, file paths and file: URIs, data: URIs, "asset:" paths under the app's resources and bytes the app holds.
platform/imageload/imageloadtest
Package imageloadtest checks a backend's imageload.HTTP against a local server, so each backend's tests hold its system client to the same behavior: status, headers both ways, the body, progress and cancelling.
Package imageloadtest checks a backend's imageload.HTTP against a local server, so each backend's tests hold its system client to the same behavior: status, headers both ways, the body, progress and cancelling.
platform/linux
Package linux is NSGo's GTK 4 backend, on NSH's Linux design: every view is a widget of its own (NsgoView, a GtkWidget subclass) that its parent places at the core's frame and that draws itself with GtkSnapshot and Cairo, text the engine measured and laid out with Pango included.
Package linux is NSGo's GTK 4 backend, on NSH's Linux design: every view is a widget of its own (NsgoView, a GtkWidget subclass) that its parent places at the core's frame and that draws itself with GtkSnapshot and Cairo, text the engine measured and laid out with Pango included.
platform/macos
Package macos is NSGo's AppKit backend: one flipped, layer-backed NSView per node, styled through its CALayer, with text the engine laid out with CoreText drawn on the main thread and images decoded off it, and an optional NSVisualEffectView material behind the window's content.
Package macos is NSGo's AppKit backend: one flipped, layer-backed NSView per node, styled through its CALayer, with text the engine laid out with CoreText drawn on the main thread and images decoded off it, and an optional NSVisualEffectView material behind the window's content.
platform/menutext
Package menutext says the labels of the menu items the backends show.
Package menutext says the labels of the menu items the backends show.
platform/perfhud
Package perfhud holds what the backends' performance panels share: the process' CPU and memory use (engine.ProcessSample) and, on Apple platforms, drawing the trace.
Package perfhud holds what the backends' performance panels share: the process' CPU and memory use (engine.ProcessSample) and, on Apple platforms, drawing the trace.
platform/picked
Package picked prepares the images a user picked as a PickRequest asks, in pure Go, for the backends whose pickers hand over files as they are: Windows and Linux.
Package picked prepares the images a user picked as a PickRequest asks, in pure Go, for the backends whose pickers hand over files as they are: Windows and Linux.
platform/privacy
Package privacy tells and asks for the permissions Apple's systems keep for the user (TCC): the macOS and iOS backends answer core's permission requests with it, and the microphone package, speech recognition and iOS's photo taking ask through it, so each permission has one implementation.
Package privacy tells and asks for the permissions Apple's systems keep for the user (TCC): the macOS and iOS backends answer core's permission requests with it, and the microphone package, speech recognition and iOS's photo taking ask through it, so each permission has one implementation.
platform/queue
Package queue hands mount batches from the engine goroutine to a platform's main thread.
Package queue hands mount batches from the engine goroutine to a platform's main thread.
platform/scrollbar
Package scrollbar is the scroll logic of the backends that keep scroll offsets of their own: where a scroll view's thumb is, whether a point is on its bar, and where dragging the thumb scrolls to; the offsets its content inset allows; and where a snapping view settles after a wheel or a thumb drag.
Package scrollbar is the scroll logic of the backends that keep scroll offsets of their own: where a scroll view's thumb is, whether a point is on its bar, and where dragging the thumb scrolls to; the offsets its content inset allows; and where a snapping view settles after a wheel or a thumb drag.
platform/textselect
Package textselect is what the Windows and Linux backends share of a selection across the texts of an area (driver.SelectionModel): the texts as the model reads them, hit-tested through their layouts.
Package textselect is what the Windows and Linux backends share of a selection across the texts of an area (driver.SelectionModel): the texts as the model reads them, hit-tested through their layouts.
platform/updates
Package updates finds a newer version of the app for the backends whose platforms have no updater of their own (updater.Check): in the app's appcast, the RSS feed in Sparkle's format that nsgo build writes, on Linux and Android, and in the App Store on iOS.
Package updates finds a newer version of the app for the backends whose platforms have no updater of their own (updater.Check): in the app's appcast, the RSS feed in Sparkle's format that nsgo build writes, on Linux and Android, and in the App Store on iOS.
platform/web
Package web is NSGo's browser backend: Go compiled to WebAssembly, one absolutely positioned element per view.
Package web is NSGo's browser backend: Go compiled to WebAssembly, one absolutely positioned element per view.
platform/webstyle
Package webstyle writes NSGo's styles as CSS, for the backends that draw with a browser's engine: the web and WeChat mini programs, whose render layer is a web view.
Package webstyle writes NSGo's styles as CSS, for the backends that draw with a browser's engine: the web and WeChat mini programs, whose render layer is a web view.
platform/windows
Package windows is NSGo's Win32 backend: one window that draws a retained tree of views with Direct2D into a flip-model swap chain on a Direct3D 11 device, text the engine laid out with DirectWrite, presses hit tested by the engine, inputs as editors of the backend's own drawn with the views (input.go), web views as WebView2 composition controllers in the window's DirectComposition tree, videos played by Media Foundation's media engine, images decoded by Go, native components' child windows following their views (component.go), files dropped through OLE (drop.go), alerts as task dialogs and updates through WinSparkle (updates.go).
Package windows is NSGo's Win32 backend: one window that draws a retained tree of views with Direct2D into a flip-model swap chain on a Direct3D 11 device, text the engine laid out with DirectWrite, presses hit tested by the engine, inputs as editors of the backend's own drawn with the views (input.go), web views as WebView2 composition controllers in the window's DirectComposition tree, videos played by Media Foundation's media engine, images decoded by Go, native components' child windows following their views (component.go), files dropped through OLE (drop.go), alerts as task dialogs and updates through WinSparkle (updates.go).
restart
Package restart starts a desktop app again once it has exited, for desktop.Restart, and keeps an app that restarts as it launches from doing so forever.
Package restart starts a desktop app again once it has exited, for desktop.Restart, and keeps an app that restarts as it launches from doing so forever.
shader
Package shader compiles shaders written in Go's syntax into the intermediate representation of package shaderir, which its backends translate for each platform's GPU API.
Package shader compiles shaders written in Go's syntax into the intermediate representation of package shaderir, which its backends translate for each platform's GPU API.
shader/wgsl
Package wgsl compiles the shaders TSX apps write in WGSL, as NSH's are, into package shaderir's programs, which every backend draws as it draws a Kage program (package shader).
Package wgsl compiles the shaders TSX apps write in WGSL, as NSH's are, into package shaderir's programs, which every backend draws as it draws a Kage program (package shader).
shaderir
Package shaderir offers intermediate representation for shader programs, forked from Ebitengine with package shader (see its documentation).
Package shaderir offers intermediate representation for shader programs, forked from Ebitengine with package shader (see its documentation).
testhost
Package testhost is where a backend built for `nsgo test -target` (the nsgotest build tag) offers its test host, and where nsgotest finds it: the platform's loop on the main thread, an app shown on a real surface, and native input at the surface's points.
Package testhost is where a backend built for `nsgo test -target` (the nsgotest build tag) offers its test host, and where nsgotest finds it: the platform's loop on the main thread, an app shown on a real surface, and native input at the surface's points.
woff
Package woff unpacks WOFF and WOFF2 font files into the TrueType or OpenType data they hold, which every platform's text engine registers.
Package woff unpacks WOFF and WOFF2 font files into the TrueType or OpenType data they hold, which every platform's text engine registers.
Package microphone records the system's default input and builds on every target, reporting where it cannot record.
Package microphone records the system's default input and builds on every target, reporting where it cannot record.
Package mobile holds what only iOS and Android have: the system's tab bar and a bar above the software keyboard, as NSH's nsh/mobile.
Package mobile holds what only iOS and Android have: the system's tab bar and a bar above the software keyboard, as NSH's nsh/mobile.
Package nsgotest runs NSGo apps in Go tests, as net/http/httptest runs handlers: headless by default, with approximate text, a manual clock and every batch applied to a model of the native views that tests query; `nsgo test -target` runs the same tests on a platform, with its native input.
Package nsgotest runs NSGo apps in Go tests, as net/http/httptest runs handlers: headless by default, with approximate text, a manual clock and every batch applied to a model of the native views that tests query; `nsgo test -target` runs the same tests on a platform, with its native input.
tools
libghostty command
Command libghostty builds libghostty-vt, Ghostty's terminal emulator as a library, for every target base/terminal runs on, desktops and iOS, from Ghostty's sources at the commit it binds, and writes the themes that Ghostty ships.
Command libghostty builds libghostty-vt, Ghostty's terminal emulator as a library, for every target base/terminal runs on, desktops and iOS, from Ghostty's sources at the commit it binds, and writes the themes that Ghostty ships.
lucidegen command
Command lucidegen imports a pinned, clean Lucide checkout and writes the lucide package: one accessor per icon, its provenance and its license.
Command lucidegen imports a pinned, clean Lucide checkout and writes the lucide package: one accessor per icon, its provenance and its license.
tsx
Package tsx runs TSX apps: bundles of what tsx/bundler emits, on the goja JavaScript engine, or the page's own on the web (internal/js), rendered by core as Go apps are.
Package tsx runs TSX apps: bundles of what tsx/bundler emits, on the goja JavaScript engine, or the page's own on the web (internal/js), rendered by core as Go apps are.
bundler
Package bundler compiles TSX apps into the scripts the tsx package runs, as NSH's bundler does (nsh-bundler): esbuild strips TypeScript, lowers syntax goja lacks and bundles the app's modules into one script, and jsx.go compiles the JSX into calls of the renderer, as NSH's compiler does.
Package bundler compiles TSX apps into the scripts the tsx package runs, as NSH's bundler does (nsh-bundler): esbuild strips TypeScript, lowers syntax goja lacks and bundles the app's modules into one script, and jsx.go compiles the JSX into calls of the renderer, as NSH's compiler does.
compiler
Package compiler runs TSX apps: App runs the bundle the nsgo tool compiled ahead (package bundler), or under go run and go test compiles the app's sources as it starts, and under nsgo dev follows the dev server's new bundles.
Package compiler runs TSX apps: App runs the bundle the nsgo tool compiled ahead (package bundler), or under go run and go test compiles the app's sources as it starts, and under nsgo dev follows the dev server's new bundles.
diff
Package diff gives TSX nsgo/base's DiffView, the changes between texts, which links packages other apps should not: an app whose TSX uses it imports this package for its effect.
Package diff gives TSX nsgo/base's DiffView, the changes between texts, which links packages other apps should not: an app whose TSX uses it imports this package for its effect.
editor
Package editor gives TSX nsgo/base's Editor, a code editor, which links packages other apps should not: an app whose TSX uses it imports this package for its effect.
Package editor gives TSX nsgo/base's Editor, a code editor, which links packages other apps should not: an app whose TSX uses it imports this package for its effect.
internal/js
Package js is the JavaScript engine package tsx runs apps on: goja on every target but the web, where the page's own engine runs them (browser.go).
Package js is the JavaScript engine package tsx runs apps on: goja on every target but the web, where the page's own engine runs them (browser.go).
pkg
Package pkg signs TSX apps into packages and verifies them, for code an app downloads: its own screens updated, or plugins.
Package pkg signs TSX apps into packages and verifies them, for code an app downloads: its own screens updated, or plugins.
richeditor
Package richeditor gives TSX nsgo/base's RichEditor and its sessions, which link packages other apps should not: an app whose TSX uses them imports this package for its effect.
Package richeditor gives TSX nsgo/base's RichEditor and its sessions, which link packages other apps should not: an app whose TSX uses them imports this package for its effect.
terminal
Package terminal gives TSX nsgo/base's Terminal, base/terminal's View over a session of its own, which links libghostty-vt's binding: an app whose TSX uses it imports this package for its effect.
Package terminal gives TSX nsgo/base's Terminal, base/terminal's View over a session of its own, which links libghostty-vt's binding: an app whose TSX uses it imports this package for its effect.
textview
Package textview gives TSX nsgo/base's TextView, Markdown and HTML documents, which links packages other apps should not: an app whose TSX uses it imports this package for its effect.
Package textview gives TSX nsgo/base's TextView, Markdown and HTML documents, which links packages other apps should not: an app whose TSX uses it imports this package for its effect.
tsxtest
Package tsxtest runs a TSX app's tests, its *.test.tsx files, as Go tests (NSH's nsh/test): each file imports nsgo/test, whose open starts the app headless, or on a platform under nsgo test -target, through nsgotest, and whose App acts as a user does.
Package tsxtest runs a TSX app's tests, its *.test.tsx files, as Go tests (NSH's nsh/test): each file imports nsgo/test, whose open starts the app headless, or on a platform under nsgo test -target, through nsgotest, and whose App acts as a user does.
ui
Package ui gives TSX nsgo/ui, package ui's components as Go components, for an app that imports this package for its effect; a theme of its own needs ui's roles, as core.DefaultTheme and ui.WarmDuskTheme have.
Package ui gives TSX nsgo/ui, package ui's components as Go components, for an app that imports this package for its effect; a theme of its own needs ui's roles, as core.DefaultTheme and ui.WarmDuskTheme have.
ui/chat
Package chat gives TSX nsgo/ui/chat, ui/chat's conversation components, for an app that imports this package for its effect beside tsx/ui.
Package chat gives TSX nsgo/ui/chat, ui/chat's conversation components, for an app that imports this package for its effect beside tsx/ui.
ui/richeditor
Package richeditor gives TSX nsgo/ui's RichEditor, ui/richeditor's View over a RichEditorSession, which links packages other apps should not: an app whose TSX uses it imports this package for its effect.
Package richeditor gives TSX nsgo/ui's RichEditor, ui/richeditor's View over a RichEditorSession, which links packages other apps should not: an app whose TSX uses it imports this package for its effect.
websrc
Package websrc holds the scripts a page's realm runs: the realm's helpers and the sources of the runtime's programs.
Package websrc holds the scripts a page's realm runs: the realm's helpers and the sources of the runtime's programs.
ui
Package ui is NSGo's built-in styled components, on base and core: colors, finishes and motion in theme.go, type and small parts in style.go, and a component to a file.
Package ui is NSGo's built-in styled components, on base and core: colors, finishes and motion in theme.go, type and small parts in style.go, and a component to a file.
chat/locales
Package locales says ui/chat's own messages in the language the app shows.
Package locales says ui/chat's own messages in the language the app shows.
commitgraph
Package commitgraph is base/commitgraph's styled form: a repository's commits as a virtualized list beside their revision graph, in the look of Onegit's All Commits page.
Package commitgraph is base/commitgraph's styled form: a repository's commits as a virtualized list beside their revision graph, in the look of Onegit's All Commits page.
diff
Package diff is base/diff's DiffView in ui's colors.
Package diff is base/diff's DiffView in ui's colors.
filepicker
Package filepicker is a modal file and folder picker, or a browser for copying paths, over a file system the app lists, possibly on another machine: places and disks in a sidebar, the browsed folder's entries in an icon or list view, and the folder's address, shown as breadcrumbs and typed into on request.
Package filepicker is a modal file and folder picker, or a browser for copying paths, over a file system the app lists, possibly on another machine: places and disks in a sidebar, the browsed folder's entries in an icon or list view, and the folder's address, shown as breadcrumbs and typed into on request.
flow
Package flow is base/flow's styled form: a directed diagram in ui's look, its lines in the muted text's color, the hovered and selected node's in the accent, and Card, a node's default face.
Package flow is base/flow's styled form: a directed diagram in ui's look, its lines in the muted text's color, the hovered and selected node's in the accent, and Card, a node's default face.
richeditor
Package richeditor is base/richeditor's View in ui's colors.
Package richeditor is base/richeditor's View in ui's colors.
Package updater keeps an app up to date the way its platform does.
Package updater keeps an app up to date the way its platform does.
locales
Package locales says the updater's words: its alerts where the platform's updater has no windows of its own.
Package locales says the updater's words: its alerts where the platform's updater has no windows of its own.
Package widget shows the app's content in widgets: on the Home Screen and the Lock Screen of iPhones and iPads, and on the desktop and in Notification Center of Macs (WidgetKit).
Package widget shows the app's content in widgets: on the Home Screen and the Lock Screen of iPhones and iPads, and on the desktop and in Notification Center of Macs (WidgetKit).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL