mainthread

package
v1.14.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: BSD-3-Clause Imports: 3 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 mainthread runs the tests of a macOS program on the main thread: AppKit works only there (SPEC §29.3), and the Go test runner runs every test on a goroutine of its own. A test binary that opens windows calls Main from TestMain; its tests then call Do, which runs a function on the main thread and waits for it. Only tests import it (it has no use in a program, which calls Run from main).

Flutter: no counterpart

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Do

func Do(fn func())

Do runs fn on the main thread and returns when it has returned. A panic of fn is raised again in the caller. fn must not call t.Fatal or runtime.Goexit: that would end the main thread's loop; it reports with t.Error and returns, and a test that waits for events does so in its own goroutine.

Flutter: no counterpart

func Main

func Main(m *testing.M)

Main runs the tests (m.Run) on a goroutine of their own while the main goroutine, which is the main thread, serves Do, and exits the process with the result. Call it as the last line of TestMain:

func TestMain(m *testing.M) { mainthread.Main(m) }

Flutter: no counterpart

Types

This section is empty.

Jump to

Keyboard shortcuts

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