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

stdin

package
v0.15.2 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package stdin is the ONLY place in the source tree allowed to read os.Stdin. Three opt-in surfaces exist:

  • JSONInput(path) is the only way command-payload JSON enters the CLI; pass "-" to mean stdin.
  • TextInput(path) is the only way non-JSON text payloads (Markdown for `adf convert`) enter the CLI; pass "-" to mean stdin.
  • SecretStdin() is the only way credential material enters the CLI via stdin; kept separate so a JSON parser never accidentally eats a secret.

Tests/contract/no_input_no_stdin_test.go and tests/guardrails/stdin_discipline_test.go enforce that no other package directly references os.Stdin.

Index

Constants

This section is empty.

Variables

View Source
var ErrEmptySecret = errors.New("stdin: --secret-stdin requested but no input received")

ErrEmptySecret is returned by SecretStdin when stdin yields no bytes — usually because the user forgot to pipe the secret in.

Functions

func JSONInput

func JSONInput(path string) (io.ReadCloser, error)

JSONInput returns a reader for the command-payload JSON. Path "-" means stdin; any other value is a regular file. The caller is responsible for closing the returned io.ReadCloser.

This is the ONLY function the CLI uses to satisfy a `--json-input <path>` flag. Adding implicit stdin reads anywhere else is forbidden by the guardrail test.

func SecretStdin

func SecretStdin() (string, error)

SecretStdin reads the entire stdin and returns the trailing-newline- trimmed secret. Used only when --secret-stdin was passed; never invoked implicitly under --no-input or any other flag.

This is the only secret-bearing stdin path.

func TextInput added in v0.7.2

func TextInput(path string) (io.ReadCloser, error)

TextInput returns a reader for a non-JSON text payload, such as the Markdown input of `adf convert`. Path "-" means stdin; any other value is a regular file. The caller closes the returned io.ReadCloser.

Types

This section is empty.

Jump to

Keyboard shortcuts

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