{"id":19855670,"url":"https://github.com/smasher164/sumgen","last_synced_at":"2025-05-02T01:31:04.580Z","repository":{"id":104710700,"uuid":"113415005","full_name":"smasher164/sumgen","owner":"smasher164","description":"sumgen generates interface method implementations from sum-type declarations.","archived":false,"fork":false,"pushed_at":"2019-12-24T23:30:04.000Z","size":17,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-26T15:50:09.980Z","etag":null,"topics":["generate","golang","interface","sum","variant"],"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/smasher164.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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-12-07T07:01:12.000Z","updated_at":"2020-10-05T05:36:02.000Z","dependencies_parsed_at":"2023-08-18T09:45:47.343Z","dependency_job_id":null,"html_url":"https://github.com/smasher164/sumgen","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/smasher164%2Fsumgen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smasher164%2Fsumgen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smasher164%2Fsumgen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smasher164%2Fsumgen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/smasher164","download_url":"https://codeload.github.com/smasher164/sumgen/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251969346,"owners_count":21673189,"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":["generate","golang","interface","sum","variant"],"created_at":"2024-11-12T14:13:24.422Z","updated_at":"2025-05-02T01:30:59.790Z","avatar_url":"https://github.com/smasher164.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"`sumgen` generates interface method implementations from sum-type declarations.\n```\ngo get -u github.com/smasher164/sumgen\n```\n\nUsage: `sumgen` is a tool intended for `go generate`, but can also be run standalone. An example declaration of a sum-type would be\n\n```\npackage main\n\n//go:generate sumgen \"Expr = KeyValueExpr | *CallExpr\"\ntype Expr interface {\n\texpr()\n}\n\ntype KeyValueExpr struct {\n\tKey   Expr\n\tColon int\n\tValue Expr\n}\ntype CallExpr struct {\n\tFun      Expr\n\tLparen   int\n\tArgs     []Expr\n\tEllipsis bool\n\tRparen   int\n}\n\nfunc main() {}\n\n```\n\nRunning `go generate` in the package directory will output the following to a file named **DIRECTORY_NAME**_sumgen.go.\n```\n// Code generated by \"sumgen\"; DO NOT EDIT.\n\npackage main\n\nfunc (_ KeyValueExpr) expr() { panic(\"default implementation\") }\nfunc (_ *CallExpr) expr()    { panic(\"default implementation\") }\n\n```\n\nEach declaration follows the following structure:\n```\nDef = LhsType \"=\" RhsType { \"|\" RhsType } .\nLhsType = identifier .\nRhsType = [ * ] identifier .\n```\n\nMore than one declaration can be be made per `interface_name`.\nTo make the `concrete_typename` a pointer receiver, simply add a `'*'` in front of it.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmasher164%2Fsumgen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsmasher164%2Fsumgen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmasher164%2Fsumgen/lists"}