template

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Replace

func Replace(s string, ctx context.Context) string

Replace replaces template variables in a string with values from context Supported variables:

  • {{worker_id}}: Current worker ID (0-based)
  • {{random_int}}: Random integer
  • {{timestamp}}: Current Unix timestamp

func ReplaceInInterface

func ReplaceInInterface(v interface{}, ctx context.Context) interface{}

ReplaceInInterface recursively replaces template variables in interface{} values Supports strings, maps, and slices

func ReplaceInMap

func ReplaceInMap(m map[string]string, ctx context.Context) map[string]string

ReplaceInMap replaces template variables in all string values of a map

Types

type ContextKey

type ContextKey string

ContextKey is a custom type for context keys to avoid collisions

const (
	// WorkerIDKey is the context key for worker ID
	WorkerIDKey ContextKey = "worker_id"
)

Jump to

Keyboard shortcuts

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