interpolate

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package interpolate substitutes "{{name}}" placeholders with variable values. It doesn't care where the values come from -- a file-scoped declaration, an environment, a script -- callers just hand it a resolved map[string]string.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Apply

func Apply(s string, vars map[string]string) (result string, missing []string)

Apply replaces every "{{name}}" placeholder in s with vars[name]. A placeholder whose name isn't in vars is left untouched in the result and its name is added to missing, in first-occurrence order with duplicates removed.

func ApplyURL

func ApplyURL(rawURL string, vars map[string]string) (result string, missing []string)

ApplyURL is like Apply, but for URLs: a "{{name}}" placeholder that lands inside a query parameter's value is percent-encoded, so a value like "Hello again" becomes "Hello%20again" instead of a literal space corrupting the request line on the wire. Placeholders anywhere else -- the scheme, host, or path -- are substituted raw, since a URL commonly builds its authority from a variable (e.g. "{{host}}/get") and that shouldn't be escaped the way a leaf value would be.

Types

This section is empty.

Jump to

Keyboard shortcuts

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