{"id":19865787,"url":"https://github.com/GaijinEntertainment/go-exhaustruct","last_synced_at":"2025-05-02T05:32:02.363Z","repository":{"id":38095004,"uuid":"471459709","full_name":"GaijinEntertainment/go-exhaustruct","owner":"GaijinEntertainment","description":"golang analyzer that finds structures with uninitialized fields","archived":false,"fork":false,"pushed_at":"2025-02-24T10:23:24.000Z","size":140,"stargazers_count":150,"open_issues_count":15,"forks_count":17,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-13T15:03:21.887Z","etag":null,"topics":["analysis","golang","lint","structures"],"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/GaijinEntertainment.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":"2022-03-18T17:32:31.000Z","updated_at":"2025-03-24T06:33:19.000Z","dependencies_parsed_at":"2023-02-05T00:15:21.579Z","dependency_job_id":"d360319d-b967-463f-8572-85b38ba5aaec","html_url":"https://github.com/GaijinEntertainment/go-exhaustruct","commit_stats":{"total_commits":98,"total_committers":5,"mean_commits":19.6,"dds":"0.30612244897959184","last_synced_commit":"64da973fd90558ad2e33ef1a3bc36d8efdfb9509"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GaijinEntertainment%2Fgo-exhaustruct","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GaijinEntertainment%2Fgo-exhaustruct/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GaijinEntertainment%2Fgo-exhaustruct/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GaijinEntertainment%2Fgo-exhaustruct/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GaijinEntertainment","download_url":"https://codeload.github.com/GaijinEntertainment/go-exhaustruct/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251992992,"owners_count":21677022,"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":["analysis","golang","lint","structures"],"created_at":"2024-11-12T15:24:12.287Z","updated_at":"2025-05-02T05:31:57.933Z","avatar_url":"https://github.com/GaijinEntertainment.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\n# exhaustruct\n\n![Package Version](https://img.shields.io/github/v/release/GaijinEntertainment/go-exhaustruct?style=flat-square)\n![Go version](https://img.shields.io/github/go-mod/go-version/GaijinEntertainment/go-exhaustruct?style=flat-square)\n![GitHub Workflow Status (with branch)](https://img.shields.io/github/actions/workflow/status/GaijinEntertainment/go-exhaustruct/ci.yml?branch=master)\n![License](https://img.shields.io/github/license/GaijinEntertainment/go-exhaustruct?style=flat-square)\n\n\n\u003c/div\u003e\n\n---\n\n`exhaustruct` is a golang analyzer that finds structures with uninitialized fields\n\n### Installation\n\n```shell\ngo get -u github.com/GaijinEntertainment/go-exhaustruct/v3/cmd/exhaustruct\n```\n\n### Usage\n\n```\nexhaustruct [-flag] [package]\n\nFlags:\n  -i value\n        Regular expression to match type names, can receive multiple flags.\n        Anonymous structs can be matched by '\u003canonymous\u003e' alias.\n        4ex:\n                github.com/GaijinEntertainment/go-exhaustruct/v3/analyzer\\.\u003canonymous\u003e\n                github.com/GaijinEntertainment/go-exhaustruct/v3/analyzer\\.TypeInfo\n        \n  -e value\n        Regular expression to exclude type names, can receive multiple flags.\n        Anonymous structs can be matched by '\u003canonymous\u003e' alias.\n        4ex:\n                github.com/GaijinEntertainment/go-exhaustruct/v3/analyzer\\.\u003canonymous\u003e\n                github.com/GaijinEntertainment/go-exhaustruct/v3/analyzer\\.TypeInfo\n```\n\n#### Comment directives\n\n`exhaustruct` supports comment directives to mark individual structures as ignored during linting or enforce it's check\nregardless global configuration. Comment directives have precedence over global configuration.\n\n- **`//exhaustruct:ignore`** - ignore structure during linting\n- **`//exhaustruct:enforce`** - enforce structure check during linting, even in case global configuration says it should\n  be ignored.\n\n\u003e Note: all directives can be placed in the end of structure declaration or on the line above it.\n\u003e\n\u003e Also, any additional comment can be placed same line right after the directive or anywhere around it, but directive\n\u003e should be at the very beginning of the line. It is _recommended_ to comment directives, especially when ignoring\n\u003e structures - it will help to understand the reason later.\n\n### Example\n\n```go\n// Package a.go\npackage a\n\ntype Shape struct {\n\tLength int\n\tWidth  int\n\n\tvolume    int\n\tPerimeter int `exhaustruct:\"optional\"`\n}\n\n// valid\nvar a Shape = Shape{\n\tLength: 5,\n\tWidth:  3,\n\tvolume: 5,\n}\n\n// invalid, `volume` is missing\nvar b Shape = Shape{\n\tLength: 5,\n\tWidth:  3,\n}\n\n// Package b.go\npackage b\n\nimport \"a\"\n\n// valid\nvar b Shape = a.Shape{\n\tLength: 5,\n\tWidth:  3,\n}\n\n// invalid, `Width` is missing\nvar b Shape = a.Shape{\n\tLength: 5,\n}\n```\n\n### Errors handling\n\nIn order to avoid unnecessary noise, when dealing with non-pointer types returned along with errors - `exhaustruct` will\nignore non-error types, checking only structures satisfying `error` interface.\n\n```go\npackage main\n\nimport \"errors\"\n\ntype Shape struct {\n\tLength int\n\tWidth  int\n}\n\nfunc NewShape() (Shape, error) {\n\treturn Shape{}, errors.New(\"error\") // will not raise an error\n}\n\ntype MyError struct {\n\tErr error\n}\n\nfunc (e MyError) Error() string {\n    return e.Err.Error()\n}\n\nfunc NewSquare() (Shape, error) {\n    return Shape{}, MyError{Err: errors.New(\"error\")} // will not raise an error\n}\n\nfunc NewCircle() (Shape, error) {\n    return Shape{}, MyError{} // will raise \"main.MyError is missing field Err\"\n}\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FGaijinEntertainment%2Fgo-exhaustruct","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FGaijinEntertainment%2Fgo-exhaustruct","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FGaijinEntertainment%2Fgo-exhaustruct/lists"}