Documentation
¶
Overview ¶
Package param provides utilities for template parameter substitution in query strings.
Index ¶
- func BindParams(template string, params map[string]any, placeholder string) (string, []any, error)
- func ExactParamName(template string) (string, bool)
- func ExtractParamNames(template string) []string
- func SubstituteInArray(data []any, params map[string]any) ([]any, error)
- func SubstituteInMap(data, params map[string]any) (map[string]any, error)
- func SubstituteParams(template string, params map[string]any) (string, []any, error)
- func SubstituteString(template string, params map[string]any) (string, error)
- func SubstituteValue(value any, params map[string]any) (any, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BindParams ¶
BindParams replaces template parameters with a positional placeholder and returns values in textual occurrence order. Repeated parameters therefore produce repeated arguments.
func ExactParamName ¶
ExactParamName returns the name of a placeholder that occupies the whole value.
func ExtractParamNames ¶
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 ¶
SubstituteInArray recursively substitutes {{paramName}} patterns in all string values throughout an array structure with any nesting depth.
func SubstituteInMap ¶
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 ¶
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 ¶
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.
Types ¶
This section is empty.