{"id":20271945,"url":"https://github.com/point-c/generator-helpers","last_synced_at":"2026-05-29T01:32:14.797Z","repository":{"id":215380150,"uuid":"738788452","full_name":"point-c/generator-helpers","owner":"point-c","description":"Utility functions for Go code generation","archived":false,"fork":false,"pushed_at":"2024-01-20T00:38:30.000Z","size":358,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-11T00:40:46.646Z","etag":null,"topics":["generated-code","golang","golang-library","helpers","templates"],"latest_commit_sha":null,"homepage":"https://point-c.github.io/generator-helpers/","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/point-c.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":"2024-01-04T03:38:03.000Z","updated_at":"2024-01-27T07:34:49.000Z","dependencies_parsed_at":null,"dependency_job_id":"f4f17cce-1463-4269-a431-1abc6e029413","html_url":"https://github.com/point-c/generator-helpers","commit_stats":null,"previous_names":["point-c/generator-helpers"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/point-c/generator-helpers","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/point-c%2Fgenerator-helpers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/point-c%2Fgenerator-helpers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/point-c%2Fgenerator-helpers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/point-c%2Fgenerator-helpers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/point-c","download_url":"https://codeload.github.com/point-c/generator-helpers/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/point-c%2Fgenerator-helpers/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33633468,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-28T02:00:06.440Z","response_time":99,"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":["generated-code","golang","golang-library","helpers","templates"],"created_at":"2024-11-14T12:40:26.007Z","updated_at":"2026-05-29T01:32:14.779Z","avatar_url":"https://github.com/point-c.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# generator_helpers\n\n[![Go Reference](https://img.shields.io/badge/godoc-reference-%23007d9c.svg)](https://point-c.github.io/generator-helpers)\n\n## Overview\n\n`generator_helpers` is a Go package designed to provide utility functions for common operations such as template generation, YAML processing, and error handling in Go applications.\n\n## Installation\n\nTo use `generator_helpers` in your Go project, you need to install it as a dependency:\n\n```bash\ngo get github.com/point-c/generator_helpers\n```\n\n## Usage\n\nBelow are some examples of how to use the `generator_helpers` package:\n\n### Unmarshalling YAML Data\n\nTo unmarshal YAML data from a file:\n\n```go\nvar config MyConfig\nerr := generator_helpers.UnmarshalYAML(\"config.yaml\", \u0026config)\nif err != nil {\n    // Handle error\n}\n```\n\n### Template Generation\n\nGenerating text or HTML from templates:\n\n```go\ntmpl, err := generator_helpers.NewTemplate[*text_template.Template](templateFS, funcs)\nif err != nil {\n    // Handle error\n}\n\nvar data MyData\ngenerator_helpers.Generate(tmpl, data, \"templateName\", \"output.txt\")\n```\n\n### Error Handling\n\nSimplifying error handling with `Must` and `Check`:\n\n```go\ngetValue := func() (int, error) { return 1, errors.New(\"error\") }\nvalue := generator_helpers.Must(getValue())\ngenerator_helpers.Check(err)\n```\n\n### Go Code Formatting\n\nThe `generator_helpers` package offers functionalities to format Go source code. Below is an example of how to use these functions:\n\n#### Formatting Go Source Code\n\nTo format a Go source code byte slice:\n\n```go\nsourceCode := []byte(\"package main\\nimport \\\"fmt\\\"\\nfunc main() {fmt.Println(\\\"hello world\\\")}\")\nformattedCode, err := generator_helpers.GoFmt(sourceCode)\nif err != nil {\n    // Handle formatting error\n}\n// Use formattedCode...\n```\n\n#### Formatting Source Code from an `io.Reader`\n\nIf you have Go source code in an `io.Reader`, you can format it as follows:\n\n```go\nvar reader io.Reader = ... // your io.Reader with Go source code\nformattedCode, err := generator_helpers.GoFmtReader(reader)\nif err != nil {\n    // Handle formatting error\n}\n// Use formattedCode...\n```\n\n## Testing\n\nThe package includes tests that demonstrate its functionality. Use Go's testing tools to run the tests:\n\n```bash\ngo test\n```\n\n## Godocs\n\nTo regenerate godocs:\n\n```bash\ngo generate -tags docs ./...\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpoint-c%2Fgenerator-helpers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpoint-c%2Fgenerator-helpers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpoint-c%2Fgenerator-helpers/lists"}