vars

package
v0.8.4 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package vars 提供轻量的 ${KEY} 变量插值,零依赖。 支持默认值语法 ${KEY:-default}(仿 shell):变量缺失时用默认值。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Render

func Render(s string, vars map[string]string) string

Render 用 vars 替换 s 中的 ${KEY} / ${KEY:-default}。 变量缺失且无默认值时替换为空串。

func RenderBytes

func RenderBytes(b []byte, vars map[string]string) []byte

RenderBytes 是 Render 的 []byte 版本,便于处理 JSON/模板等字节内容。

func RenderFunc

func RenderFunc(s string, resolve func(key string) (string, bool)) string

RenderFunc 用自定义解析函数替换 ${KEY} / ${KEY:-default}。 resolve 返回 (值, 是否存在);不存在且无默认值时替换为空串。

Types

This section is empty.

Jump to

Keyboard shortcuts

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