{"id":20806874,"url":"https://github.com/link-society/gotempl","last_synced_at":"2026-03-05T11:31:48.253Z","repository":{"id":43481792,"uuid":"432565314","full_name":"link-society/gotempl","owner":"link-society","description":"Generic templating tool with support of JSON, YAML and TOML data","archived":false,"fork":false,"pushed_at":"2025-09-01T06:41:49.000Z","size":79,"stargazers_count":9,"open_issues_count":3,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-10-09T08:38:54.892Z","etag":null,"topics":["golang","json","template","toml","yaml"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/link-society.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-11-27T22:07:54.000Z","updated_at":"2025-04-27T06:04:34.000Z","dependencies_parsed_at":"2025-04-24T13:20:56.774Z","dependency_job_id":"dd14b769-fb2c-4fd4-b04a-2626a13a5ef4","html_url":"https://github.com/link-society/gotempl","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/link-society/gotempl","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/link-society%2Fgotempl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/link-society%2Fgotempl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/link-society%2Fgotempl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/link-society%2Fgotempl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/link-society","download_url":"https://codeload.github.com/link-society/gotempl/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/link-society%2Fgotempl/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30122121,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-05T11:11:57.947Z","status":"ssl_error","status_checked_at":"2026-03-05T11:11:29.001Z","response_time":93,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["golang","json","template","toml","yaml"],"created_at":"2024-11-17T19:28:00.929Z","updated_at":"2026-03-05T11:31:48.079Z","avatar_url":"https://github.com/link-society.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gotempl\n\nSmall binary used to generate files from Go Templates, environment variables\nand data files.\n\nThe following formats are supported:\n\n- JSON\n- YAML\n- TOML\n- ENV (environment variables in the form \"key=value\")\n\n## Usage\n\n```text\nusage: gotempl [--help] [--completion] [--html] [--template TEMPLATE [TEMPLATE ...]] [--output OUTPUT] [--data DATA [DATA ...]] [--data-json DATA-JSON [DATA-JSON ...]] [--data-yaml DATA-YAML [DATA-YAML ...]] [--data-toml DATA-TOML [DATA-TOML ...]] [--data-env DATA-ENV [DATA-ENV ...]]\n\nGeneric templating tool which use both environment variables and data files as template data\n\noptions:\n  --help, -h                           show this help message\n  --completion                         show command completion script\n  --html, -H                           Escape template for HTML output\n  --template TEMPLATE, -t TEMPLATE     Path to Go Template file. Default is stdin.\n  --output OUTPUT, -o OUTPUT           Path to output file. Default is stdout\n  --data DATA, -d DATA                 Data value of type name=value to be used in template. Can be used multiple times.\n  --data-json DATA-JSON, -j DATA-JSON  Path to JSON file\n  --data-yaml DATA-YAML, -y DATA-YAML  Path to YAML file\n  --data-toml DATA-TOML, -T DATA-TOML  Path to TOML file\n  --data-env DATA-ENV, -e DATA-ENV     Path to ENV file\n```\n\n### Example: Basic usage\n\nLet's create a file named `greeting.template` containing the following:\n\n```tmpl\nHello {{ .Data.name }}\n```\n\nUsing ***gotempl***, you can then render this file to:\n\n```bash\n$ gotempl -t greeting.template --data name=\"John Smith\"\nHello John Smith\n```\n\n### Example: Rendering JSON\n\nLet's create a file named `sample.json` containing the following:\n\n```json\n{\n  \"name\": \"John Smith\"\n}\n```\n\nAnd a file named `greeting.template` containing the following:\n\n```tmpl\nHello {{ .Data.name }}\n```\n\nUsing **gotempl**, you can then render those files to:\n\n```bash\n$ gotempl -t greeting.template --data-json sample.json\nHello John Smith\n```\n\n### Example: Rendering multiple files\n\nLet's create a file named `greeting.yaml` containing the following:\n\n```yaml\ngreeting:\n  polite: Good morning\n  informal: Hi\n```\n\nThen a file `sample.json` containing the following:\n\n```json\n{\n  \"informal\": true,\n  \"name\": \"John\"\n}\n```\n\nAnd finally, a file `greeting.template` containing the following:\n\n```tmpl\n{{- if .Data.informal -}}\n{{ .Data.greeting.informal }} {{ .Data.name }}\n{{- else -}}\n{{ .Data.greeting.polite }} {{ .Data.name }}\n{{- end -}}\n```\n\nUsing **gotempl**, you can then render those files to:\n\n```bash\n$ gotempl -t greeting.template --data-yaml greeting.yaml --data-json sample.json\nHi John\n```\n\n### Example: Reading template from stdin\n\nUsing the previous `sample.json` file and **gotempl**, you can render it to:\n\n```bash\n$ export GREETING=\"Hello\"\n$ cat \u003c\u003cEOF | gotempl --data-json sample.json\n{{ .Env.GREETING }} {{ .Data.name }}\nEOF\nHello John\n```\n\n### Example: Using Sprig\n\n**gotempl** supports [Sprig functions](http://masterminds.github.io/sprig/):\n\n```bash\n$ export STR=\"hello\"\n$ cat \u003c\u003cEOF | gotempl\n{{ .Env.STR | upper | repeat 5 }}\nEOF\nHELLOHELLOHELLOHELLOHELLO\n```\n\n### Example: Using local file functions\n\n**gotempl** supports read file functions such as\n\n| names | description |\n|-|-|\n| isDir, osIsDir | test if input path is a directory |\n| readDir, osReadDir | returns input path files |\n| readFile, osReadFile | returns input path file content |\n| walkDir, osWalkDir | returns recursively input path files and directory content |\n| fileExists, osFileExists | true if input file path exists |\n\n```bash\n$ cat \u003c\u003cEOF | gotempl\n{{ isDir \".\" }}\nEOF\ntrue\n```\n\n## Contributing\n\nTo add a new supported format, you'll need to implement the following interface:\n\n```go\ntype Decoder {\n  Format()        string        // return the format name, used for the --data-*** option\n  Shortcut()      string        // return the shortcut option to use\n  Decode([]byte)  (Data, error) // unmarhsal the input data\n}\n```\n\nThe add your implementation to the decoder list in `internal/decoder/main.go`:\n\n```go\nvar decoders = []Decoder{\n  //...\n  MyDecoder{},\n}\n```\n\n## License\n\nThis project is released under the terms of the [MIT License](./LICENSE.txt).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flink-society%2Fgotempl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flink-society%2Fgotempl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flink-society%2Fgotempl/lists"}