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

compat

package
v1.4.14 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package compat is the single switch ADR 0021 requires for every P7 change that breaks an existing user-visible behaviour.

The rule: patch releases keep shipping from main, so a breaking change lands dormant. The old (v1.4) behaviour stays the default; the new (v1.5) behaviour runs only when V15 reports true. There is exactly one switch, one environment variable (EnvVar) and one marker format. A per-feature flag, a second switch or a build tag for P7 behaviour is not allowed.

V15 is true when NSELF_V15 is "1" or "true" (any case). Unset, empty, "0" and any other value are false. The value is read from the environment on every call and never cached, so tests flip it with t.Setenv.

Marker format: the line directly above (or the same line as) every gated call to V15 carries

// compat.V15(<ticket-id>): <old behaviour> -> <new behaviour>

scripts/ci/compat-markers.sh lists every marker as "<file>:<line> <ticket-id>", fails when a call has no marker, and renders the "Gated behaviours" table of .github/wiki/Compat-V15.md from the comments.

P7-SHIP flips the default to v1.5 and deletes the old branches.

Layer: L0. This package imports the standard library only.

Index

Constants

View Source
const EnvVar = "NSELF_V15"

EnvVar is the environment variable that selects v1.5 behaviour.

Variables

This section is empty.

Functions

func Mode

func Mode() string

Mode returns the active compat mode as a string: "v1.5" when V15 is true, otherwise "v1.4".

func V15

func V15() bool

V15 reports whether v1.5 behaviour is selected: true iff NSELF_V15 is "1" or "true" in any case. It reads the environment on every call.

Types

This section is empty.

Directories

Path Synopsis
Package compattest runs a test body in both ADR 0021 compat modes.
Package compattest runs a test body in both ADR 0021 compat modes.

Jump to

Keyboard shortcuts

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