{"id":18801565,"url":"https://github.com/ghostiam/protogetter","last_synced_at":"2025-04-05T04:08:30.697Z","repository":{"id":192937065,"uuid":"687772217","full_name":"ghostiam/protogetter","owner":"ghostiam","description":"Protobuf golang linter - use getters instead of fields.","archived":false,"fork":false,"pushed_at":"2025-03-17T21:41:06.000Z","size":136,"stargazers_count":26,"open_issues_count":3,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-28T14:11:27.466Z","etag":null,"topics":["golang","golang-grpc","golang-linter","grpc-go","linter","protobuf"],"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/ghostiam.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":"2023-09-06T01:19:09.000Z","updated_at":"2025-03-19T17:17:34.000Z","dependencies_parsed_at":"2024-06-21T19:06:15.631Z","dependency_job_id":"99c79319-43b5-480b-8329-1cbd50b7ff60","html_url":"https://github.com/ghostiam/protogetter","commit_stats":null,"previous_names":["ghostiam/protogolint","ghostiam/protogetter"],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ghostiam%2Fprotogetter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ghostiam%2Fprotogetter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ghostiam%2Fprotogetter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ghostiam%2Fprotogetter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ghostiam","download_url":"https://codeload.github.com/ghostiam/protogetter/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247284942,"owners_count":20913704,"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":["golang","golang-grpc","golang-linter","grpc-go","linter","protobuf"],"created_at":"2024-11-07T22:24:24.781Z","updated_at":"2025-04-05T04:08:30.656Z","avatar_url":"https://github.com/ghostiam.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Protogetter\nWelcome to the Protogetter project!\n\n## Overview\nProtogetter is a linter developed specifically for Go programmers working with nested `protobuf` types.\\\nIt's designed to aid developers in preventing `invalid memory address or nil pointer dereference` errors arising from direct access of nested `protobuf` fields.\n\nWhen working with `protobuf`, it's quite common to have complex structures where a message field is contained within another message, which itself can be part of another message, and so on.\nIf these fields are accessed directly and some field in the call chain will not be initialized, it can result in application panic.\n\nProtogetter addresses this issue by suggesting use of getter methods for field access.\n\n## How does it work?\nProtogetter analyzes your Go code and helps detect direct `protobuf` field accesses that could give rise to panic.\\\nThe linter suggests using getters:\n```go\nm.GetFoo().GetBar().GetBaz()\n```\ninstead of direct field access:\n```go\nm.Foo.Bar.Baz\n```\n\nAnd you will then only need to perform a nil check after the final call:\n```go\nif m.GetFoo().GetBar().GetBaz() != nil {\n    // Do something with m.GetFoo().GetBar().GetBaz()\n}\n```\ninstead of:\n```go\nif m.Foo != nil {\n    if m.Foo.Bar != nil {\n        if m.Foo.Bar.Baz != nil {\n            // Do something with m.Foo.Bar.Baz\n        }\n    }\n}\n```\n\nor use zero values:\n\n```go\n// If one of the methods returns `nil` we will receive 0 instead of panic.\nv := m.GetFoo().GetBar().GetBaz().GetInt() \n```\n\ninstead of panic:\n\n```go\n// If at least one structure in the chains is not initialized, we will get a panic. \nv := m.Foo.Bar.Baz.Int\n```\n\nwhich simplifies the code and makes it more reliable.\n\n## Installation\n\n```bash\ngo install github.com/ghostiam/protogetter/cmd/protogetter@latest\n```\n\n## Usage\n\nTo run the linter:\n```bash\nprotogetter ./...\n```\n\nOr to apply suggested fixes directly:\n```bash\nprotogetter --fix ./...\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fghostiam%2Fprotogetter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fghostiam%2Fprotogetter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fghostiam%2Fprotogetter/lists"}