{"id":29574710,"url":"https://github.com/nao1215/vogen","last_synced_at":"2026-02-12T00:36:21.373Z","repository":{"id":270528879,"uuid":"909203186","full_name":"nao1215/vogen","owner":"nao1215","description":"vogen - Value Object Generator in golang","archived":false,"fork":false,"pushed_at":"2025-11-21T14:16:00.000Z","size":46,"stargazers_count":2,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-02-10T21:07:50.186Z","etag":null,"topics":["golang","library","value-object"],"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/nao1215.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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},"funding":{"github":"nao1215"}},"created_at":"2024-12-28T02:35:01.000Z","updated_at":"2025-02-22T00:47:27.000Z","dependencies_parsed_at":"2025-01-01T02:10:27.411Z","dependency_job_id":"b7b7e31a-3e77-4679-b4c9-c4feb2d14436","html_url":"https://github.com/nao1215/vogen","commit_stats":null,"previous_names":["nao1215/vogen"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/nao1215/vogen","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nao1215%2Fvogen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nao1215%2Fvogen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nao1215%2Fvogen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nao1215%2Fvogen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nao1215","download_url":"https://codeload.github.com/nao1215/vogen/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nao1215%2Fvogen/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29351055,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-11T20:11:40.865Z","status":"ssl_error","status_checked_at":"2026-02-11T20:10:41.637Z","response_time":97,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["golang","library","value-object"],"created_at":"2025-07-19T08:39:31.370Z","updated_at":"2026-02-12T00:36:21.359Z","avatar_url":"https://github.com/nao1215.png","language":"Go","funding_links":["https://github.com/sponsors/nao1215"],"categories":[],"sub_categories":[],"readme":"## vogen - Value Object Generator in golang\n\u003c!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section --\u003e\n[![All Contributors](https://img.shields.io/badge/all_contributors-1-orange.svg?style=flat-square)](#contributors-)\n\u003c!-- ALL-CONTRIBUTORS-BADGE:END --\u003e\n\n[![Go Reference](https://pkg.go.dev/badge/github.com/nao1215/vogen.svg)](https://pkg.go.dev/github.com/nao1215/vogen)\n![Coverage](https://raw.githubusercontent.com/nao1215/octocovs-central-repo/main/badges/nao1215/vogen/coverage.svg)\n[![reviewdog](https://github.com/nao1215/vogen/actions/workflows/reviewdog.yml/badge.svg)](https://github.com/nao1215/vogen/actions/workflows/reviewdog.yml)\n[![MultiPlatformUnitTest](https://github.com/nao1215/vogen/actions/workflows/unit_test.yml/badge.svg)](https://github.com/nao1215/vogen/actions/workflows/unit_test.yml)\n\nThe vogen library is to generate value objects in golang. The vogen will automatically generate files with Value Objects defined.\n  \nThe vogen automatically generates Getter, Constructor, Constructor with Validation, and Equal() based on metadata (vogen.ValueObject).\n\n## Supported OS and go version\n- OS: Linux, macOS, Windows\n- Go: 1.22 or later\n\n## Example\n### Implement a value object metadata\n\nFirstly, write your value object metadata. Here is an example: gen/main.go\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"path/filepath\"\n\n\t\"github.com/nao1215/vogen\"\n)\n\n//go:generate go run main.go\n\nfunc main() {\n\t// Step 1: Create a Vogen instance with custom file path and package name.\n\t// By default, the file path is \"value_objects.go\" and the package name is \"vo\".\n\tgen, err := vogen.New(\n\t\tvogen.WithFilePath(filepath.Join(\"testdata\", \"example_output.go\")),\n\t\tvogen.WithPackageName(\"vo_example\"),\n\t)\n\tif err != nil {\n\t\tfmt.Printf(\"Failed to create Vogen instance: %v\\n\", err)\n\t\treturn\n\t}\n\n\t// Step 2: Append the ValueObject definition\n\tif err := gen.AppendValueObjects(\n\t\tvogen.ValueObject{\n\t\t\tStructName: \"Person\",\n\t\t\tFields: []vogen.Field{\n\t\t\t\t{\n\t\t\t\t\tName: \"Name\", Type: \"string\",\n\t\t\t\t\tComments: []string{\"Name is the name of the person.\"},\n\t\t\t\t\tValidators: []vogen.Validator{\n\t\t\t\t\t\tvogen.NewStringLengthValidator(0, 120),\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tName: \"Age\", Type: \"int\",\n\t\t\t\t\tComments: []string{\"Age is the age of the person.\"},\n\t\t\t\t\tValidators: []vogen.Validator{\n\t\t\t\t\t\tvogen.NewPositiveValueValidator(),\n\t\t\t\t\t\tvogen.NewMaxValueValidator(120),\n\t\t\t\t\t}},\n\t\t\t},\n\t\t\tComments: []string{\n\t\t\t\t\"Person is a Value Object to describe the feature of vogen.\",\n\t\t\t\t\"This is sample comment.\",\n\t\t\t},\n\t\t},\n\t); err != nil {\n\t\tfmt.Printf(\"Failed to append ValueObject: %v\\n\", err)\n\t\treturn\n\t}\n\n\t// Step 3: Generate the code\n\tif err := gen.Generate(); err != nil {\n\t\tfmt.Printf(\"Failed to generate code: %v\\n\", err)\n\t\treturn\n\t}\n}\n```\n\nIf you run 'go generate ./...', the following code will be generated in the `example_vo.go` file.\n\n```go\n// Code generated by vogen. DO NOT EDIT.\npackage vo_example\n\nimport (\n\t\"fmt\"\n)\n\n// Person is a Value Object to describe the feature of vogen.\n// This is sample comment.\ntype Person struct {\n\t// Name is the name of the person.\n\tname string\n\t// Age is the age of the person.\n\tage int\n}\n\n// NewPerson creates a new instance of Person.\nfunc NewPerson(name string, age int) Person {\n\treturn Person{name: name, age: age}\n}\n\n// NewPersonStrictly creates a new instance of Person with validation.\nfunc NewPersonStrictly(name string, age int) (Person, error) {\n\to := Person{name: name, age: age}\n\tif len(o.name) \u003c 0 || len(o.name) \u003e 120 {\n\t\treturn fmt.Errorf(\"struct 'Person' field 'Name' length is out of range: %d\", len(o.name))\n\t}\n\tif o.age \u003c 0 {\n\t\treturn fmt.Errorf(\"struct 'Person' field 'Age' value is negative: %d\", age)\n\t}\n\tif o.age \u003e 120 {\n\t\treturn fmt.Errorf(\"struct 'Person' field 'Age' value exceeds the maximum value: %d\", age)\n\t}\n\treturn o, nil\n}\n\n// Name returns the name field.\nfunc (o Person) Name() string {\n\treturn o.name\n}\n\n// Age returns the age field.\nfunc (o Person) Age() int {\n\treturn o.age\n}\n\n// Equal checks if two Person objects are equal.\nfunc (o Person) Equal(other Person) bool {\n\treturn o.Name() == other.Name() \u0026\u0026 o.Age() == other.Age()\n}\n\n// Address represents a value object.\ntype Address struct {\n\tcity string\n}\n\n// NewAddress creates a new instance of Address.\nfunc NewAddress(city string) Address {\n\treturn Address{city: city}\n}\n\n// City returns the city field.\nfunc (o Address) City() string {\n\treturn o.city\n}\n\n// Equal checks if two Address objects are equal.\nfunc (o Address) Equal(other Address) bool {\n\treturn o.City() == other.City()\n}\n```\n\n### Validation list\n\n| Validator | Description |\n| --- | --- |\n| NewPositiveValueValidator() | Check if the value is positive. |\n| NewNegativeValueValidator() | Check if the value is negative. |\n| NewMaxValueValidator(max int) | Check if the value is less than to the maximum value. |\n| NewMinValueValidator(min int) | Check if the value is greater than to the minimum value. |\n| NewStringLengthValidator(min, max int) | Check if the length of the string is within the specified range. |\n\n## License\n\n[MIT License](./LICENSE)\n\n## Contribution\n\nFirst off, thanks for taking the time to contribute! See [CONTRIBUTING.md](./CONTRIBUTING.md) for more information. Contributions are not only related to development. For example, GitHub Star motivates me to develop! Please feel free to contribute to this project.\n\n\n## Contributors ✨\n\nThanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --\u003e\n\u003c!-- prettier-ignore-start --\u003e\n\u003c!-- markdownlint-disable --\u003e\n\u003ctable\u003e\n  \u003ctbody\u003e\n    \u003ctr\u003e\n      \u003ctd align=\"center\" valign=\"top\" width=\"14.28%\"\u003e\u003ca href=\"https://debimate.jp/\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/22737008?v=4?s=75\" width=\"75px;\" alt=\"CHIKAMATSU Naohiro\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eCHIKAMATSU Naohiro\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/nao1215/vogen/commits?author=nao1215\" title=\"Code\"\u003e💻\u003c/a\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n  \u003c/tbody\u003e\n\u003c/table\u003e\n\n\u003c!-- markdownlint-restore --\u003e\n\u003c!-- prettier-ignore-end --\u003e\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:END --\u003e\n\nThis project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnao1215%2Fvogen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnao1215%2Fvogen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnao1215%2Fvogen/lists"}