webview

package
v1.0.10 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2026 License: AGPL-3.0 Imports: 13 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package webview shows web pages in native windows, with a tray icon, from a pure Go program: WebView2 on Windows (through the COM interface, see github.com/jchv/go-webview2), WKWebView on macOS and WebKitGTK on Linux (both through purego, without cgo). See docs/desktop-app.md for why and for what each platform can do.

Only the RemoHop desktop app (cmd/remohop-quick) links this package. On Linux purego makes a CGO_ENABLED=0 binary dynamically linked against the C library (it has to load GTK), so the remohop command line tool, which must stay a static binary, never imports it; cmd/remohop's tests check that.

Threads

Every windowing system here wants its windows created and driven from one thread, and macOS insists on the process's first thread. Importing this package locks the main goroutine to that thread (an init function calling runtime.LockOSThread), so Run must be called from the main goroutine: cli.Main runs commands there. Everything an App does must run on that thread too: in Run's setup function or in a function given to App.Dispatch, which may be called from any goroutine.

Index

Constants

This section is empty.

Variables

View Source
var ErrUnavailable = nativeui.ErrUnavailable

ErrUnavailable means this system has no usable native web view.

Functions

func Run

func Run(cfg Config, setup func(App)) error

Run starts the native application, calls setup on the UI thread and runs the event loop until App.Quit. It must be called from the main goroutine (see the package comment). If the system has no native web view it returns an error wrapping ErrUnavailable without calling setup.

func SelfTest

func SelfTest(clip string, timeout, hold time.Duration) (map[string]any, error)

SelfTest opens a native window with a page that probes WebCodecs and decodes clip (an H.264 Annex B stream with access unit delimiters; "" skips the decode), and returns what the page reported. The window stays open for hold after the report, so that a test can take a screenshot. Like Run, it must be called from the main goroutine.

func SelfTestBrowser

func SelfTestBrowser(clip string, timeout time.Duration, start func(url string) (stop func(), err error)) (map[string]any, error)

SelfTestBrowser runs the same page in a browser instead: start is called with the page's address and must open it (and may return a process to end afterwards). It is the comparison for SelfTest.

Types

type App

type App = nativeui.App

The types are nativeui's; this package implements them.

type Config

type Config = nativeui.Config

The types are nativeui's; this package implements them.

type Info

type Info = nativeui.Info

The types are nativeui's; this package implements them.

func Probe

func Probe() (Info, error)

Probe reports whether Run can show native windows here, without creating any. ErrUnavailable (possibly wrapped) means it cannot.

type MenuItem = nativeui.MenuItem

The types are nativeui's; this package implements them.

type Options

type Options = nativeui.Options

The types are nativeui's; this package implements them.

type Tray

type Tray = nativeui.Tray

The types are nativeui's; this package implements them.

type Window

type Window = nativeui.Window

The types are nativeui's; this package implements them.

Jump to

Keyboard shortcuts

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