gotmpl

command module
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

README

gotmpl

gotmpl is a tool to generate files from templates and JSON data.

Usage

Usage of gotmpl:
  -b, --body string   Template body filepath.
  -d, --data string   Data in JSON format.
  -o, --out string    Output filepath.

Background

gotmpl has been created as one of the solutions to avoid depending on internal packages of different modules. Such dependencies could transitively lead to build failure when an internal package API introduces a non-backward compatible change.

gotmpl can be used for sharing non-exported common code across multiple Go modules. It is advised to keep the shared code in a separate internal Go module (e.g. under internal/shared). The shared code should be consumed across modules using go generate, for example:

//go:generate gotmpl --body=../internal/shared/env.go.tmpl "--data={ \"pkg\": \"jaeger\" }" --out=env.go

Documentation

Overview

gotmpl is a tool to generate files from text/template and JSON data.

Jump to

Keyboard shortcuts

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