{"id":20635720,"url":"https://github.com/tada-team/bang","last_synced_at":"2026-04-19T07:32:09.157Z","repository":{"id":57621476,"uuid":"392868812","full_name":"tada-team/bang","owner":"tada-team","description":"go:generate from .yml","archived":false,"fork":false,"pushed_at":"2021-08-13T21:23:30.000Z","size":13,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-16T08:28:39.303Z","etag":null,"topics":["codegeneration","codegenerator","go","go-generate","golang","yml"],"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/tada-team.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-08-05T01:32:27.000Z","updated_at":"2023-04-13T10:30:29.000Z","dependencies_parsed_at":"2022-09-26T20:01:49.539Z","dependency_job_id":null,"html_url":"https://github.com/tada-team/bang","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/tada-team/bang","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tada-team%2Fbang","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tada-team%2Fbang/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tada-team%2Fbang/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tada-team%2Fbang/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tada-team","download_url":"https://codeload.github.com/tada-team/bang/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tada-team%2Fbang/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271722251,"owners_count":24809662,"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","status":"online","status_checked_at":"2025-08-22T02:00:08.480Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["codegeneration","codegenerator","go","go-generate","golang","yml"],"created_at":"2024-11-16T15:06:52.073Z","updated_at":"2026-04-19T07:32:04.115Z","avatar_url":"https://github.com/tada-team.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Bang\n\nSugar for `go generate`. \n\nReads yml data from .go source file and render template with variables.\n\n### How to use it\n\n1. Install:\n```bash\ngo install github.com/tada-team/bang\n```\n\n2. Write line `//go:generate bang $GOFILE:$GOLINE`, and `//`-commented yaml content below:\n\n```go\npackage mypackage\n\n//go:generate bang $GOFILE:$GOLINE\n//  \n//  ...yaml...\n//\n```\n\nYaml format is:\n\n```yaml\ntemplate: \u003cgo template contents\u003e\nvars: \u003cvariables for template\u003e\ndest: \u003cfilename for saving rendered template\u003e\n```\n\n3. run `go generate`\n\nTemplate will be rendered and code wil be formatted.\n\n### Example\n```go\npackage main\n\n//go:generate bang $GOFILE:$GOLINE\n// dest: main_generated.go\n// vars:\n//   package: main\n//   types:\n//    - int\n//    - float64\n// template: \u003e\n//   package {{ .package }}\n//\n//   {{ range $type := .types }}\n//       func {{ $type }}Sum(a, b {{ $type }}) {{ $type }} {\n//           return a + b\n//       }\n//   {{ end }}\n//\n```\n\nResult (`main_generated.go`):\n\n```go\n// Code generated by Bang.go DO NOT EDIT.\n\npackage main\n\nfunc intSum(a, b int) int {\n\treturn a + b\n}\n\nfunc float64Sum(a, b float64) float64 {\n\treturn a + b\n}\n```\n\n### Optional command line flags\n\n* `-dest` argument overrides `dest` key in yaml\n* `-template` argument takes `template` from given template file\n* `-vars` argument takes `vars` from given yaml file\n* `-verbose` argument adds more output\n\nExample: \n\n```go\npackage main\n\n//go:generate bang -verbose -dest=main_generated.go -template=main.tpl $GOFILE:$GOLINE\n```\n\n`vars.tpl`:\n```yaml\npackage: main\ntypes:\n - int\n - float64\n```\n\n`main.tpl`:\n```gotemplate\npackage {{ .package }}\n\n{{ range $type := .types }}\n  func {{ $type }}Sum(a, b {{ $type }}) {{ $type }} {\n    return a + b\n  }\n{{ end }}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftada-team%2Fbang","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftada-team%2Fbang","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftada-team%2Fbang/lists"}