duplex

command
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2026 License: MIT Imports: 27 Imported by: ? 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

Command duplex is the bidirectional stream example: an embedded page talks to Go services over ipc streams that carry JSON and bytes both ways.

  • Echo: the page sends JSON and bytes, Go writes each frame back (Router.HandleDuplex, Stream.Receive / Write / WriteBytes).
  • Upload: file.stream().pipeTo(stream.writable); Go writes the bytes to a temporary file as they arrive and reports progress on the same stream.
  • Terminal: a local shell (Go "Term", os/exec pipes through Stream.ReadWriter) driven by the page's stream.readable/writable.
  • Go panel (-panel): a Go-drawn card over the page that uses the same Echo service in process (Router.Open), next to the page's own.
  • Benchmark: 64 B echo latency (p50/p99) and 64 KiB throughput in both directions, printed as one JSON line.

Run it with:

go run ./examples/duplex          # interactive
go run ./examples/duplex -panel   # with the Go-drawn Echo panel
go run ./examples/duplex -bench   # runs the benchmark, prints JSON, quits

-page NAME loads another page of frontend/ instead of index.html, e.g. probe.html, the WebKit streaming probe of internal/platform/darwin's TestStreamingDeliveryProbe (needs TANGO_SCHEME_PROBE=1 and, on macOS, a development build: -tags tango_dev, which automation adds), or csp.html, the app's page under a CSP that blocks fetch to the asset origin (TestLaneCSPBlocked; a test route, needs TANGO_SCHEME_PROBE=1).

TANGO_SCHEME_PROBE=1 also adds the test routes (/__test/...) and the "Debug.Stats" ipc method of package services, used by the scheme handler and lane tests of internal/platform/darwin. On macOS the backend's own counters in Debug.Stats (and the bench's upMain) and TANGO_IPC_LANES_DARWIN=all need a development build too (go run -tags tango_dev ./examples/duplex); a plain build reports the counters as zero and treats =all like the default. frontend/iframe.html is a same-origin subframe page for TestLaneSubframeAccess.

With -tags tango_selftest or tango_dev, TANGO_SCHEME_SELFTEST=1 runs the desktop lane self-test, prints one selftest result and quits.

Directories

Path Synopsis
Package services holds the ipc services shared by the duplex examples (examples/duplex on the desktop, examples/duplex-mobile on iOS).
Package services holds the ipc services shared by the duplex examples (examples/duplex on the desktop, examples/duplex-mobile on iOS).

Jump to

Keyboard shortcuts

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