{"id":20877215,"url":"https://github.com/badu/stroo","last_synced_at":"2025-08-27T01:40:01.084Z","repository":{"id":57508685,"uuid":"227986079","full_name":"badu/stroo","owner":"badu","description":"Generator using template which sit in your projects - no dependency required","archived":false,"fork":false,"pushed_at":"2023-03-07T00:27:15.000Z","size":2343,"stargazers_count":3,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-01T07:53:34.317Z","etag":null,"topics":["generator","go","golang","structs","template","tool"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/badu.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":"2019-12-14T07:50:57.000Z","updated_at":"2024-12-26T23:18:28.000Z","dependencies_parsed_at":"2024-11-18T06:57:30.627Z","dependency_job_id":"5affdb02-e6b4-47b1-882c-9aea552b3a02","html_url":"https://github.com/badu/stroo","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/badu%2Fstroo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/badu%2Fstroo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/badu%2Fstroo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/badu%2Fstroo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/badu","download_url":"https://codeload.github.com/badu/stroo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253766062,"owners_count":21960840,"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":["generator","go","golang","structs","template","tool"],"created_at":"2024-11-18T06:56:20.004Z","updated_at":"2025-05-12T15:32:48.841Z","avatar_url":"https://github.com/badu.png","language":"Go","readme":"# stroo\n[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fbadu%2Fstroo.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fbadu%2Fstroo?ref=badge_shield)\n\n\nEver got tired of writing a `Stringer` implementation over and over again? Wanted to implement `Marshaler` and `Unmarshaler` for `json` package?\n\nIndeed, there are all sort of tools to generate code, but all of them are forcing you to take their own road. How about working with templates instead?\nThus you could carry your template around with your project, customizing it and having no worries that the way it is being used would change.\n\nThis tool traverses Go AST using the static checker of the [Go Tools](golang.org/x/tools). After traversal, it produces information regarding structs, functions and interfaces that are being declared in the inspected package. That information is exposed to a template that you, the developer, define. In the end, the generated code - using that template - will be written into a file of your choice. \n\n## How\n\nHaving the following declaration:\n\n```go\npackage model\n//go:generate stroo -type=SomeJsonPayload -output=model_json_gen.go -template=./../../templates/json_marshal.tmpl\n//go:generate stroo -type=SomeJsonPayload -output=model_json_gen.go -template=./../../templates/json_unmarshal.tmpl\ntype SomeJsonPayload struct{\n\tName string `json:\"name\"`\n}\n```\n\nstroo will use the template (relative path in the example `json_marshal.tmpl` and `json_unmarshal.tmpl`) to generate the files indicated as output, in the same package with the struct declaration.\n\n## Install\n\nAs usual, install like any other Go tool.\n\n## Playground\n\nYes, there is a playground to help you build templates. By default, the first `type` definition from the source is passed to your template and you should have at least one.\n\n### Notes\n\nDevelopers can store and retrieve information inside a template : templates can store and retrieve key-values by using `{{ .Store \u003ckey\u003e \u003cvalue\u003e }}` and retrieve them with `{{ .Retrieve \u003ckey\u003e }}` where \u003ckey\u003e is a `string` and \u003cvalue\u003e is `interface{}`.\n\nThis repository contains code taken (and modified) from [internal go tools](golang.org/x/tools/go/analysis/internal/checker) because the package is internal and cannot be imported. \n\nThank you good authors!\n\n### Wiki\n\n[Here](https://github.com/badu/stroo/wiki) is the wiki.\n\n## License\n[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fbadu%2Fstroo.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fbadu%2Fstroo?ref=badge_large)","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbadu%2Fstroo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbadu%2Fstroo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbadu%2Fstroo/lists"}