{"id":34514126,"url":"https://github.com/koykov/inspector","last_synced_at":"2026-01-20T16:37:51.919Z","repository":{"id":39751129,"uuid":"250793493","full_name":"koykov/inspector","owner":"koykov","description":"Inspection framework for arbitrary Go structs.","archived":false,"fork":false,"pushed_at":"2025-11-30T19:20:49.000Z","size":985,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-03T04:17:37.779Z","etag":null,"topics":["dynamic-instrumentation","highload","inspection","reflection-free"],"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/koykov.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license.md","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2020-03-28T12:49:03.000Z","updated_at":"2025-11-30T19:20:53.000Z","dependencies_parsed_at":"2024-04-01T16:50:53.052Z","dependency_job_id":"c549d0be-7e3d-48d9-9ee3-2ad62d13bb4d","html_url":"https://github.com/koykov/inspector","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/koykov/inspector","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koykov%2Finspector","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koykov%2Finspector/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koykov%2Finspector/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koykov%2Finspector/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/koykov","download_url":"https://codeload.github.com/koykov/inspector/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koykov%2Finspector/sbom","scorecard":{"id":568755,"data":{"date":"2025-08-11","repo":{"name":"github.com/koykov/inspector","commit":"b7d77ef37aa037e7e38e45b7013c16a700c257d4"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":4.3,"checks":[{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Code-Review","score":0,"reason":"Found 0/14 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":10,"reason":"16 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 10","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: license.md:0","Info: FSF or OSI recognized license: MIT License: license.md:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 30 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-20T15:44:14.232Z","repository_id":39751129,"created_at":"2025-08-20T15:44:14.232Z","updated_at":"2025-08-20T15:44:14.232Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":27994565,"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-12-24T02:00:07.193Z","response_time":83,"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":["dynamic-instrumentation","highload","inspection","reflection-free"],"created_at":"2025-12-24T04:18:15.734Z","updated_at":"2025-12-24T04:18:16.344Z","avatar_url":"https://github.com/koykov.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Inspector\n\nInspector is a code-generation framework of special wrappers of arbitrary types and data structures that allows to\nread/write/iterate fields without using reflection and produce minimum or zero allocations.\n\nEach type-wrapper (next \"inspector\" or \"type-inspector\") has name of original type with suffix `Inspector` and implements\n[Inspector](https://github.com/koykov/inspector/blob/master/inspector.go#L4) interface.\n\n## Intro\n\nThe main idea: you may read/write/iterate (inspect) structure of arbitrary type in common way. The historical reason of\ndevelopment that framework was [dyntpl](https://github.com/koykov/dyntpl) package and many others. Usually this problem\nsolves using reflection, but that way is extremely slow in general and produces huge amount of allocs on every use of\n`reflect.Value` type. There is good library [reflect2](https://github.com/modern-go/reflect2) that solves 'reflect.Value'\nproblem, but it is also slow. The perfect way if to use `type assertion` together with hardcoded combinations of all\npossible paths to type fields. Unfortunately this way isn't a pure \"dynamic solution\". Let's consider that problem using\nexample:\n\nLet we have type [`T`](https://github.com/koykov/versus/blob/master/inspector2/types/types.go#L3):\n```go\ntype T struct {\n    L1 *L1\n}\n\ntype L1 struct {\n    L2 *L2\n}\n\ntype L2 struct {\n    L3 *L3\n}\n\ntype L3 struct {\n    S string\n    I int64\n    F float64\n}\n```\nwith many nested subtypes. And we need to read data of fields for arbitrary path, eg:\n* `obj.L1.L2.L3.S`\n* `obj.L1.L2.L3.F`\n* ...\n\nThe hard requirement is a \"dynamic\" paths to fields - at any time may require to read value of any field.\n\nLet's check how that problem may be solved ob [showcase](https://github.com/koykov/versus/tree/master/inspector2):\n\n### reflect\n\nSolution https://github.com/koykov/versus/blob/master/inspector2/reflect.go#L8\n\nIt's a pure dynamic solution, it [solves the problem](https://github.com/koykov/versus/blob/master/inspector2/reflect_test.go#L7),\nbut [benchmark](https://github.com/koykov/versus/blob/master/inspector2/reflect_test.go#L11) looks bad:\n```\nBenchmarkReflect/obj.L1.L2.L3.S-8         \t 3119121\t       375.6 ns/op\t      64 B/op\t       5 allocs/op\n```\nSpeed is not acceptable and too many allocations - they will trigger problems with GC.\n\n### reflect2\n\nSolution https://github.com/koykov/versus/blob/master/inspector2/reflect2.go#L12\n\nIt's also pure dynamic solution, and it should solve problem with allocations (cost of use `reflect.Value`). It's true,\nbut benchmarks shows problems:\n```\nBenchmarkReflect2/obj.L1.L2.L3.S-8         \t 2973918\t       391.3 ns/op\t       0 B/op\t       0 allocs/op\n```\nAllocations problem is solved, but speed is much worse than native reflect due to internal design of `reflect2.frozenConfig`\n(it uses `sync.Map` inside and speed reduces due to sync operations).\n\n### inspector\n\nSolution https://github.com/koykov/versus/blob/master/inspector2/inspector_test.go#L13\nBenchmark https://github.com/koykov/versus/blob/master/inspector2/inspector_test.go#L18\n```\nBenchmarkInspector/obj.L1.L2.L3.S-8         \t159301698\t         7.596 ns/op\t       0 B/op\t       0 allocs/op\n```\nAnd that speed is acceptable. See explanation is the next chapter.\n\n## How it works\n\nAs mentioned, the perfect way is using `type assertion` together with hardcoded combinations of all possible paths to\ntype fields, i.e. zero reflection. Type `T` allows the following paths combinations:\n* `obj.L1.L2.L3.S`\n* `obj.L1.L2.L3.I`\n* `obj.L1.L2.L3.F`\n* `obj.L1.L2.L3`\n* `obj.L1.L2`\n* `obj.L1`\n\nType is simple, thus has only 6 combinations. The code considers these combinations looks the following https://github.com/koykov/versus/blob/master/inspector2/inspector2_ins/t_ins.go#L31.\nSo primitive and thus so fast.\n\nBut what about big types? They provide hundreds/thousands combinations and write code manually is so big and boring work.\nThe further support is a problem as well. Therefore, this work was automatized writing special [code-generation tool](https://github.com/koykov/inspector/tree/master/inspc).\n\n## Additional features\n\nFields values reading is so important feature, but inspectors also provide features:\n* [write values to fields](https://github.com/koykov/inspector/blob/master/inspector.go#L12)\n* [compare fields values](https://github.com/koykov/inspector/blob/master/inspector.go#L17)\n* [iterate iterable fields](https://github.com/koykov/inspector/blob/master/inspector.go#L19) по заданному пути\n* [deep comparison of a whole types](https://github.com/koykov/inspector/blob/master/inspector.go#L21) по заданному пути\n* [deep copy of types](https://github.com/koykov/inspector/blob/master/inspector.go#L27)\n* [reset types](https://github.com/koykov/inspector/blob/master/inspector.go#L35)\n\n## Basic types support\n\n### static\n\nFor support of basic types (int, uint, float64, ...) was developed special [static](https://github.com/koykov/inspector/blob/master/static.go)\ninspector. It uses in [dyntpl](https://github.com/koykov/dyntpl) and [decoder](https://github.com/koykov/decoder)\npackages for primitive types.\n\n### strings\n\nSpecial for types `string` and `[][]byte` was developed inspector [strings](https://github.com/koykov/inspector/blob/master/strings.go).\nSee [test/bench](https://github.com/koykov/inspector/blob/master/test/strings_test.go).\n\n### map[string]any\n\nPopular type uses together with `encoding/json` supported by inspector [map\\[string\\]any](https://github.com/koykov/inspector/blob/master/stranymap.go).\nSee test/bench https://github.com/koykov/inspector/blob/master/test/stranymap_test.go\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkoykov%2Finspector","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkoykov%2Finspector","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkoykov%2Finspector/lists"}