gomplate
$ gomplate 社区开源 低风险gomplate 支持渲染 Go text/template 文件(-f)或内联模板(-i),可挂载丰富的数据源(-d alias=file.yaml、JSON、CSV、TOML、HTTP、Vault、AWS SSM)并内置 200+ 辅助函数(data.ToJSON、coll.JQ、crypto)。
brew install gomplate 用单一静态 Go 二进制确定性地从 YAML/JSON/CSV 数据源渲染结构化模板(gomplate -d cfg=data.yaml -f tmpl.gotmpl)。
Agent 友好度体检单
当前为静态评估(本机尚未安装或尚未运行探针)。可在本地运行 npm run data:probe 并提交 data/probes/ 升级为实测证据。
FCRS-1.0 六维评分拆解
完全非交互运行,支持 -f、-i 内联模板、-d 数据源、-o 输出及内置 data.ToJSON / data.ToYAML 函数。
- Supports
-d,-f,-i,-o, anddata.ToJSON
默认只写标准输出;仅显式指定 -o 或 --output-dir 时写入本地文件(高级插件/模板模式下存在 exec 函数)。
- Stdout default; explicit
-o/--output-dirrequired for writes
单一静态 Go 二进制覆盖 macOS、Linux 与 Windows,支持 Homebrew、go install 与 GitHub Releases。
- Static Go binary (
brew install gomplate)
单二进制集成了 JSON、YAML、CSV、TOML、环境变量及 Vault/SSM 数据源与 200+ 模板函数。
- Multi-format datasource ingestion and Go template rendering
由 Dave Henderson(hairyhenderson/gomplate v4)在 MIT 协议下活跃维护。
- Active
hairyhenderson/gomplaterepository
docs.gomplate.ca 文档体系完善,详述所有 CLI 参数、数据源与函数命名空间。
- Comprehensive docs at docs.gomplate.ca
安全边界、鉴权与放权指南
本地数据源无需凭据;可选的 Vault/AWS/Consul 数据源读取 VAULT_TOKEN、AWS_* 或标准提供商环境变量。
MIT 开源 CLI,完全免费。
# gomplate Agent Rules - Preview rendered output on stdout first (omit `-o` / `--output-dir`) before writing files. - Use explicit `-d alias=path` datasources and avoid HTTP/Vault datasource URLs unless explicitly intended.
Agent 高频安全命令配方
只读查询(安全推荐)
gomplate -d cfg=data.yaml -f tmpl.gotmpl
以别名 cfg 加载 data.yaml 并将渲染结果打印到标准输出,不写盘。
gomplate -d data=users.csv -i '{{ (ds "data") | data.ToJSON }}' 通过 -i 内联解析 users.csv 并使用 data.ToJSON 输出 JSON。
受控写入与预演
gomplate -d cfg=data.yaml -f config.tmpl -o config.json
通过 -o(--out)将渲染结果写入 config.json。
核心优势
- + 通过
-d alias=file原生读取 JSON、YAML、CSV 与 TOML 数据源。 - + 单一静态 Go 二进制,支持
-i内联求值与data.ToJSON转换。 - + 未指定
-o或--output-dir时默认安全输出至标准输出。
注意事项与踩坑点
- ! Go
text/template的空白裁剪({{- ... -}})与ds语法在 Shell 命令中需注意引号转义。 - ! 模板中的
vault://、aws+sm://、https://数据源会触发外部网络或凭据访问。