{"id":23158782,"url":"https://github.com/mitchs-dev/build-struct","last_synced_at":"2025-09-05T10:38:19.177Z","repository":{"id":255443740,"uuid":"851723670","full_name":"mitchs-dev/build-struct","owner":"mitchs-dev","description":"Convert JSON/YAML -\u003e GO struct","archived":false,"fork":false,"pushed_at":"2025-03-27T09:56:20.000Z","size":28,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-04T18:47:16.121Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/mitchs-dev.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-09-03T15:50:25.000Z","updated_at":"2025-03-27T09:56:23.000Z","dependencies_parsed_at":"2024-12-17T22:29:37.362Z","dependency_job_id":"3697b90f-eb51-4933-8192-36c012e21913","html_url":"https://github.com/mitchs-dev/build-struct","commit_stats":null,"previous_names":["mitchs-dev/build-struct"],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/mitchs-dev/build-struct","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitchs-dev%2Fbuild-struct","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitchs-dev%2Fbuild-struct/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitchs-dev%2Fbuild-struct/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitchs-dev%2Fbuild-struct/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mitchs-dev","download_url":"https://codeload.github.com/mitchs-dev/build-struct/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitchs-dev%2Fbuild-struct/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273747256,"owners_count":25160649,"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","status":"online","status_checked_at":"2025-09-05T02:00:09.113Z","response_time":402,"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":[],"created_at":"2024-12-17T22:27:37.807Z","updated_at":"2025-09-05T10:38:14.148Z","avatar_url":"https://github.com/mitchs-dev.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# build-struct\n\nThis is a simple command line tool which converts a given configuration file into a Go struct. It accepts a configuration file in JSON or YAML format. The tool looks at the content within the configuration file, not necessarily the file extension. I designed it this way as sometimes I use `config` instead of `config.yaml` so I wanted it to be flexible.\n\n## Use Case\n\nFor my personal use case, I have structs which have a lot of fields and I have to manually create them. This tool helps me to automate the process of creating structs.\n\n## Installation\n\n```bash\ngo install github.com/mitchs-dev/build-struct@latest\n```\n\n## Usage\n\n```bash\nbuild-struct \u003cstruct-name\u003e \u003cpath-to-config-file\u003e\n```\n\n## Example\n\nI have a configuration file (`config.yaml`) with the following content:\n\n```yaml\napiVersion: v1\nmetadata:\n  name: my-app\n  namespace: default\nsettings:\n  logging: \n    debug: false\n    format: json\n  database:\n    host: localhost\n    port: 5432\n    username: root\n    password: password\n  data:\n  - path: /var/data\n    threshold: 0.80\n    enable: true\n    size: 100Gi\n  - path: /var/log\n    threshold: 0.90\n    enable: true\n    size: 10Gi\n```\n\nI can run the following command:\n\n```bash\n\nbuild-struct Config config.yaml\n```\n\nThis will generate the following Go struct:\n\n```go\ntype Config struct {\n        ApiVersion string `yaml:\"apiVersion\"`\n        Metadata struct {\n                Name string `yaml:\"name\"`\n                Namespace string `yaml:\"namespace\"`\n        } `yaml:\"metadata\"`\n        Settings struct {\n                Logging struct {\n                        Debug bool `yaml:\"debug\"`\n                        Format string `yaml:\"format\"`\n                } `yaml:\"logging\"`\n                Database struct {\n                        Password string `yaml:\"password\"`\n                        Host string `yaml:\"host\"`\n                        Port int `yaml:\"port\"`\n                        Username string `yaml:\"username\"`\n                } `yaml:\"database\"`\n                Data []struct {\n                        Threshold float64 `yaml:\"threshold\"`\n                        Enable bool `yaml:\"enable\"`\n                        Size string `yaml:\"size\"`\n                        Path string `yaml:\"path\"`\n                } `yaml:\"data\"`\n        } `yaml:\"settings\"`\n}\n```\n\n## Caveats\n\n- `[]byte` values are a bit tricky to handle. If you need to support `[]byte` values, you will have to manually update the generated struct. The suggested approach is to use `string` instead of `[]byte` in the configuration file.\n\n## Contributing\n\nIf you have any suggestions or improvements, feel free to open an issue or a pull request.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmitchs-dev%2Fbuild-struct","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmitchs-dev%2Fbuild-struct","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmitchs-dev%2Fbuild-struct/lists"}