Documentation
¶
Overview ¶
Package singleinstance enforces a single running instance of an app and forwards a later launch's args to the primary (e.g. to focus a window or handle a deep link) instead of starting a second backend. Pure Go and cross-platform: it uses a per-app loopback address; the first instance to bind it is primary, and later instances connect and forward. An ACK handshake ensures an unrelated program on the same port is never mistaken for our primary.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Instance ¶
type Instance struct {
// contains filtered or unexported fields
}
Instance is the primary's handle; Close releases the lock.
func Acquire ¶
Acquire attempts to become the primary instance for appID. If it succeeds it returns (instance, true, nil) and begins listening. If another instance holds the lock, it forwards args to it and returns (nil, false, nil) — the caller should exit. On error the caller should start normally (single-instance best effort).