{"id":28657653,"url":"https://github.com/ksrichard/gogen","last_synced_at":"2025-06-13T09:13:40.479Z","repository":{"id":57562741,"uuid":"331300051","full_name":"ksrichard/gogen","owner":"ksrichard","description":"Powerful dynamic template based generation","archived":false,"fork":false,"pushed_at":"2021-02-15T09:20:23.000Z","size":400,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-05-01T13:29:11.712Z","etag":null,"topics":["archetype-generator","generator","project","template","utility"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ksrichard.png","metadata":{"files":{"readme":"README.MD","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-01-20T12:27:31.000Z","updated_at":"2021-12-16T16:11:14.000Z","dependencies_parsed_at":"2022-09-17T14:10:50.863Z","dependency_job_id":null,"html_url":"https://github.com/ksrichard/gogen","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/ksrichard/gogen","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ksrichard%2Fgogen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ksrichard%2Fgogen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ksrichard%2Fgogen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ksrichard%2Fgogen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ksrichard","download_url":"https://codeload.github.com/ksrichard/gogen/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ksrichard%2Fgogen/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259616402,"owners_count":22884887,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["archetype-generator","generator","project","template","utility"],"created_at":"2025-06-13T09:13:39.337Z","updated_at":"2025-06-13T09:13:40.469Z","avatar_url":"https://github.com/ksrichard.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Logo](images/logo.png)\n\n[![Go Report Card](https://goreportcard.com/badge/github.com/ksrichard/gogen)](https://goreportcard.com/report/github.com/ksrichard/gogen)\n[![Go Reference](https://pkg.go.dev/badge/github.com/ksrichard/gogen.svg)](https://pkg.go.dev/github.com/ksrichard/gogen)\n[![GitHub go.mod Go version of a Go module](https://img.shields.io/github/go-mod/go-version/ksrichard/gogen.svg)](https://github.com/ksrichard/gogen)\n[![GitHub release](https://img.shields.io/github/release/ksrichard/gogen.svg)](https://github.com/ksrichard/gogen/releases/latest/)\n\nCode coverage: https://gocover.io/github.com/ksrichard/gogen\n\n# gogen\nA simple CLI and library to generate any kind of projects from any kind of templates! (just like maven archetype, but its much easier)\nThis CLI tool can be a very good replacement of `sed` commands when need to replace several values in configuration files.\n\nThere is absolutely no limitation in programming language or whatever you want to generate from a file and directory based template!\n\n## Features\n- Generating output from any kind of folder/file structure\n- Uses the famous [Mustache](https://mustache.github.io/) templating engine for directory name, file name, file content generation\n\n## Options\n```\n./gogen generate --help\nGenerating projects/folder structures based on a template\n\nUsage:\n  gogen generate [flags]\n\nFlags:\n  -h, --help                    help for generate\n  -i, --input string            Template folder/file to be used for generation\n  -o, --output string           Output folder/file where result will be generated\n                                Not applicable when output type is 'stdout'!\n  -t, --output-type string      Output type - file,folder,stdout.\n                                Not applicable when input is a folder! (default \"folder\")\n  -v, --vars stringToString     Variables for generation (default [])\n  -f, --vars-file stringArray   Variables from file (YAML) for generation\n```\nYou can use everything in directory/file names and files content that can be done in [Mustache](https://mustache.github.io/) (for loops etc...)\n\n**Note**: Here when you pass any variables to the generator, they will be used for generating both folder/file names and contents of files!\n**Note**: When you use multiple sources for variables (more files and/or inline parameters), the order of the overwriting values is the following:\n- all YAML files in order\n- all command line parameters\n\n## Installation\nYou can install the CLI using homebrew (or local build, see next section):\n```\nbrew tap ksrichard/tap\nbrew install gogen\n```\n\n## Example usages of CLI\n- Build the CLI using the following command executed in root of the project: `go build`\n**Note:** You can combine any of the input/output, output types parameters to fit to your needs of course!\n\n    - Generate a project/folder structure:\n    ```\n    ./gogen generate -i examples/simple-project/ -o output/GoTest -v module=GoTest -v project_name=\"Go Test\"\n    ```\n    See the output folder that was generated (and also check for file contents):\n    ![Logo](images/screenshot1.png)\n    \n    - Generate single file:\n    ```\n    ./gogen generate -i ./examples/simple-project/main.go -t stdout -v project_name=\"Test Project\"\n    ```\n    - Generate single file to file output:\n    ```\n    ./gogen generate -i ./examples/simple-project/main.go -t file -o test.go -v project_name=\"Test Project\"\n    ```\n    - Generate using variables from file, template from pipe:\n    ```bash\n    echo \"{{testRootValue}} --\u003e\u003e {{#projects}}\\\"{{name}},{{url}} -\u003e {{#data}}{{value}}{{/data}}\\\" {{/projects}}\" | ./gogen generate -t stdout -f ./examples/test.yaml\n    ```\n    - Generate using variables from file (properties overwrite from another file), template from pipe:\n    ```bash\n    echo \"{{testRootValue}} --\u003e\u003e {{#projects}}\\\"{{name}},{{url}} -\u003e {{#data}}{{value}}{{/data}}\\\" {{/projects}}\" | ./gogen generate -t stdout -f ./examples/test.yaml -f ./examples/test2.yaml\n    ```\n    - Generate using variables from file (properties overwrite from command line option), template from pipe:\n    ```bash\n    echo \"{{testRootValue}} --\u003e\u003e {{#projects}}\\\"{{name}},{{url}} -\u003e {{#data}}{{value}}{{/data}}\\\" {{/projects}}\" | ./gogen generate -t stdout -f ./examples/test.yaml -v testRootValue=\"someTest2\"\n    ```\n    - Generate using variables from file (properties overwrite from command line option), template from pipe:\n    ```bash\n    echo \"{{testRootValue}} --\u003e\u003e {{#projects}}\\\"{{name}},{{url}} -\u003e {{#data}}{{value}}{{/data}}\\\" {{/projects}}\" | ./gogen generate -t stdout -f ./examples/test.yaml -v testRootValue=\"someTest2\"\n    ```\n\n## Example usage of Library\n```go\npackage main\n\nimport (\n\tgogen \"github.com/ksrichard/gogen/service\"\n)\n\nfunc main() {\n\terr := gogen.Generate(\"examples/simple-project\", \"output/GoTest\", \"folder\", map[string]interface{\n\t\t\"module\": \"GoTest\",\n\t\t\"project_name\": \"Go Test\",\n\t})\n\tif err != nil {\n\t\tpanic(err)\n\t}\n}\n```\n\n## TODO (upcoming features)\n- [x] Support input from stdin\n- [x] Generate result from single file template\n  - [x] Add support to print result instead of writing to file/output directory\n- [x] Support more complex variables than just simple string key -\u003e value ones\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fksrichard%2Fgogen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fksrichard%2Fgogen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fksrichard%2Fgogen/lists"}