param

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2026 License: Apache-2.0 Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package param provides utilities for template parameter substitution in query strings.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BindParams

func BindParams(template string, params map[string]any, placeholder string) (string, []any, error)

BindParams replaces template parameters with a positional placeholder and returns values in textual occurrence order. Repeated parameters therefore produce repeated arguments.

func ExactParamName

func ExactParamName(template string) (string, bool)

ExactParamName returns the name of a placeholder that occupies the whole value.

func ExtractParamNames

func ExtractParamNames(template string) []string

ExtractParamNames returns the ordered list of parameter names found in the template string. Parameter names are extracted from {{name}} patterns. Returns the names in the order they first appear, with duplicates removed.

func SubstituteInArray

func SubstituteInArray(data []any, params map[string]any) ([]any, error)

SubstituteInArray recursively substitutes {{paramName}} patterns in all string values throughout an array structure with any nesting depth.

func SubstituteInMap

func SubstituteInMap(data, params map[string]any) (map[string]any, error)

SubstituteInMap recursively substitutes {{paramName}} patterns in all string values throughout a map structure with any nesting depth. Arrays and nested maps are handled. Non-string values are left unchanged.

func SubstituteParams

func SubstituteParams(template string, params map[string]any) (string, []any, error)

SubstituteParams replaces all {{paramName}} patterns with values from the params map. Returns the substituted string and an ordered slice of values matching parameter order. Returns error if a required parameter (referenced in template) is missing from params.

func SubstituteString

func SubstituteString(template string, params map[string]any) (string, error)

SubstituteString replaces {{paramName}} patterns in a string with provided values. Useful for path strings where we want the actual values, not positional markers. Returns error if a required parameter is missing.

func SubstituteValue

func SubstituteValue(value any, params map[string]any) (any, error)

SubstituteValue recursively substitutes {{paramName}} in a value that may be a string, map, array, or primitive JSON value.

Types

This section is empty.

Jump to

Keyboard shortcuts

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