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

configenv

package
v1.151.0 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package configenv expands ${VAR} and ${VAR:-default} placeholders in a configuration document before it is parsed.

It is its own package rather than a corner of pkg/platform because the substitution rule is a contract two audiences depend on -- every shipped config writes against it, and every operator reads a failure through it -- and because pkg/platform is at its size budget: a package that must not grow is not where a self-contained rule belongs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckNoPlaceholders added in v1.151.0

func CheckNoPlaceholders(config map[string]any) error

CheckNoPlaceholders refuses a database-managed connection config carrying a "${...}" placeholder.

The platform expands ${VAR} in its configuration FILE, before that document is parsed. A connection stored through this API is not that document: its values are used exactly as they arrive, so a placeholder is stored verbatim and the connection is unusable from the moment it is created — the store answers 200, the connection lists and reads correctly, and every call against it fails several layers away at DSN construction with "invalid userinfo" (#1805). Refusing here is the difference between learning that at the PUT and learning it from a script that already ran half of a pipeline.

It walks nested maps and slices because a connection config is not flat: an api connection's static headers and a toolkit's per-tool settings are objects of their own, and a placeholder in one of them is the same defect.

func Expand

func Expand(s string) string

Expand expands ${VAR} and ${VAR:-default} patterns in the string.

func Unexpanded added in v1.133.4

func Unexpanded(s string) []string

Unexpanded returns the distinct "${" fragments standing in s, in the order they appear. An empty result means every placeholder was substituted, or that there were none.

Expansion is a configuration-FILE feature: a value that arrives any other way is used exactly as it was written. So the same fragment this package warns about in a file is, for a caller that stores a value directly, always a mistake — a database-managed connection holding "${TRINO_USER}" as its username is stored, listed and reported as created, and fails every call afterwards at DSN construction (#1805). Exported so that caller can refuse it at the point it is written rather than warn about it at startup.

Types

This section is empty.

Jump to

Keyboard shortcuts

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