{"id":21261879,"url":"https://github.com/nchern/go-codegen","last_synced_at":"2025-07-11T03:32:42.931Z","repository":{"id":57524598,"uuid":"87989524","full_name":"nchern/go-codegen","owner":"nchern","description":"Yet another code generator for golang; generics included","archived":false,"fork":false,"pushed_at":"2023-07-30T08:01:48.000Z","size":359,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-06-20T19:24:13.934Z","etag":null,"topics":["automation","code-generation","code-generator","codegen","generic","golang","gotools"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nchern.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-04-11T23:49:35.000Z","updated_at":"2023-04-16T12:13:44.000Z","dependencies_parsed_at":"2024-06-20T19:13:10.706Z","dependency_job_id":null,"html_url":"https://github.com/nchern/go-codegen","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nchern%2Fgo-codegen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nchern%2Fgo-codegen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nchern%2Fgo-codegen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nchern%2Fgo-codegen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nchern","download_url":"https://codeload.github.com/nchern/go-codegen/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225674968,"owners_count":17506272,"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":["automation","code-generation","code-generator","codegen","generic","golang","gotools"],"created_at":"2024-11-21T04:56:10.163Z","updated_at":"2024-11-21T04:56:10.997Z","avatar_url":"https://github.com/nchern.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Go Report Card](https://goreportcard.com/badge/github.com/nchern/go-codegen)](https://goreportcard.com/report/github.com/nchern/go-codegen)\n[![Coverage](https://gocover.io/_badge/github.com/nchern/go-codegen)](https://gocover.io/github.com/nchern/go-codegen)\n\n\n# go-codegen\n\nWith a lack of templates some of the gophers really miss them...\nYet another attempt of code generaton in Golang.\n\n## Testing\n```bash\nmake test # generates code and runs tests\n```\n\n## Install\n```bash\nmake install\n```\n\n## Usage\n```bash\n# Prints help\n$ go-codegen -h\n```\n\n### Generics\n\n#### Usage\n```bash\n# Outputs built-in string to int map implementation to stdout\ngo-codegen generic -t=hashmap string int\n\n# Reads generic source from file pkg/generic/list/list.go and outputs typed implementation to stdout\ngo-codegen generic -f pkg/generic/list/list.go string\n\n# More help on available built-ins and other command line params\ngo-codegen help generic\n```\n\nGenerics are implemented by parsing an input go source file into an AST and substituting predefined \"generic\" types. Currently only a fixed list of such types is supported: `T0, T1, ..., T5`. The advantage of such approach as the generic implementation(input source) is the correct go source that can be tested.\nSee build-ins as [examples](pkg/generic/list/list.go) of how to define a generic type.\nSee [test code](tests/generic) for more examples.\n\n### Immutables\n\n#### Usage\n```bash\n# Gets a .go source file with defined interfaces and outputs implementation along with builder class to create instances\ngo-codegen --pkg=model immutable -f tests/immutable/model/model.go\n```\n\nAn experiment. Inspired by Java Immutables. See more examples in [test code](tests/immutable/).\n\n### Constructor\n\nGenerates constructor function for struct. More details see [here](docs/constructor.md).\n\n### Impl\n\nGenerates interface implementations stubs. More details see [here](docs/impl.md).\n\n## Nice to have\n\n * Integration with [gen](http://alikewise.com/gen/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnchern%2Fgo-codegen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnchern%2Fgo-codegen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnchern%2Fgo-codegen/lists"}