Help us shape the future of Go! Take the 2026 Go Developer Survey

wslg

package
v1.27.0-beta.2 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: MPL-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package wslg discovers an explicitly selected WSL user's display connection values. It never imports a shell environment or grants access to GUI sockets.

Index

Constants

View Source
const (
	Display        = "DEVSY_WSLG_DISPLAY"
	WaylandDisplay = "DEVSY_WSLG_WAYLAND_DISPLAY"
	RuntimeDir     = "DEVSY_WSLG_XDG_RUNTIME_DIR"
)

Variables

View Source
var (
	ErrUnsupported = errors.New(
		"WSLg discovery requires native Windows and a local Docker runtime",
	)
	ErrInvalidTarget = errors.New("WSLg discovery requires an explicit non-root WSL distro/user")
	ErrExecutable    = errors.New("WSLg discovery cannot locate the Windows system wsl.exe")
	ErrProtocol      = errors.New(
		"WSLg probe failed; verify the selected distro/user and /usr/bin/printenv",
	)
	ErrUnavailable = errors.New(
		"WSLg has no usable DISPLAY or WAYLAND_DISPLAY for the selected user; " +
			"check that the distribution is running and WSLg is enabled",
	)
	ErrCollision = errors.New("reserved WSLg environment assignment")
)

Functions

func CheckCollisions

func CheckCollisions(source string, env []string, windows bool) error

func CheckEnvironmentSources

func CheckEnvironmentSources(sources map[string][]string, windows bool) error

CheckEnvironmentSources rejects assignments before provider construction can log its effective environment or start a runtime.

func Overlay

func Overlay(base []string, env map[string]string, windows bool) []string

Overlay replaces the reserved entries, including Windows case variants, once. Ordinary environment precedence remains the caller's responsibility.

func Pairs

func Pairs(env map[string]string) []string

func Reserved

func Reserved(key string, windows bool) bool

func ValidateEnvironment

func ValidateEnvironment(env map[string]string) error

func ValidateTarget

func ValidateTarget(target Target) error

Types

type ProbeResult

type ProbeResult struct {
	Stdout   []byte
	Stderr   []byte
	ExitCode int
}

type Runner

type Runner interface {
	Run(context.Context, string, []string) (ProbeResult, error)
}

type Snapshot

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

Snapshot contains only present keys; an empty string is distinct from absence. Accessors return copies so an invocation cannot mutate another's environment.

func Capture

func Capture(ctx context.Context, target Target, path string, runner Runner) (*Snapshot, error)

Capture exposes the bounded probe for tests; production always resolves the trusted executable using the Windows system API in Discover.

func Discover

func Discover(ctx context.Context, target Target) (*Snapshot, error)

func NewSnapshot

func NewSnapshot(target Target, env map[string]string) (*Snapshot, error)

func (*Snapshot) Environment

func (s *Snapshot) Environment() map[string]string

func (*Snapshot) Target

func (s *Snapshot) Target() Target

type Target

type Target struct {
	Distro string `json:"distro"`
	User   string `json:"user"`
}

Jump to

Keyboard shortcuts

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