{"id":43756525,"url":"https://github.com/goldeneggg/structil","last_synced_at":"2026-02-05T14:31:29.488Z","repository":{"id":39261221,"uuid":"189685353","full_name":"goldeneggg/structil","owner":"goldeneggg","description":"Go struct utilities with reflection for JSON data decoding, map-liked data accessing, dynamic struct building and more","archived":false,"fork":false,"pushed_at":"2024-09-03T22:12:16.000Z","size":715,"stargazers_count":50,"open_issues_count":5,"forks_count":8,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-17T12:50:23.809Z","etag":null,"topics":["decoder","go","golang","json","json-parser","structs"],"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/goldeneggg.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":"2019-06-01T03:21:43.000Z","updated_at":"2024-02-17T12:38:36.000Z","dependencies_parsed_at":"2024-06-18T18:38:56.009Z","dependency_job_id":null,"html_url":"https://github.com/goldeneggg/structil","commit_stats":null,"previous_names":[],"tags_count":23,"template":false,"template_full_name":null,"purl":"pkg:github/goldeneggg/structil","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goldeneggg%2Fstructil","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goldeneggg%2Fstructil/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goldeneggg%2Fstructil/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goldeneggg%2Fstructil/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/goldeneggg","download_url":"https://codeload.github.com/goldeneggg/structil/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goldeneggg%2Fstructil/sbom","scorecard":{"id":434623,"data":{"date":"2025-08-11","repo":{"name":"github.com/goldeneggg/structil","commit":"73c8790aded769b43dd5a478990febb93e2af89a"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.9,"checks":[{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Code-Review","score":0,"reason":"Found 0/3 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":"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":"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":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","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":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/benchmark.yml:1","Warn: no topLevel permission defined: .github/workflows/ci.yml:1","Info: no jobLevel write permissions found"],"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":"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":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Pinned-Dependencies","score":1,"reason":"dependency not pinned by hash detected -- score normalized to 1","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/benchmark.yml:42: update your workflow using https://app.stepsecurity.io/secureworkflow/goldeneggg/structil/benchmark.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/benchmark.yml:48: update your workflow using https://app.stepsecurity.io/secureworkflow/goldeneggg/structil/benchmark.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/benchmark.yml:52: update your workflow using https://app.stepsecurity.io/secureworkflow/goldeneggg/structil/benchmark.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/benchmark.yml:73: update your workflow using https://app.stepsecurity.io/secureworkflow/goldeneggg/structil/benchmark.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/benchmark.yml:85: update your workflow using https://app.stepsecurity.io/secureworkflow/goldeneggg/structil/benchmark.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/benchmark.yml:102: update your workflow using https://app.stepsecurity.io/secureworkflow/goldeneggg/structil/benchmark.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/benchmark.yml:107: update your workflow using https://app.stepsecurity.io/secureworkflow/goldeneggg/structil/benchmark.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:40: update your workflow using https://app.stepsecurity.io/secureworkflow/goldeneggg/structil/ci.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:46: update your workflow using https://app.stepsecurity.io/secureworkflow/goldeneggg/structil/ci.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:50: update your workflow using https://app.stepsecurity.io/secureworkflow/goldeneggg/structil/ci.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yml:72: update your workflow using https://app.stepsecurity.io/secureworkflow/goldeneggg/structil/ci.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:114: update your workflow using https://app.stepsecurity.io/secureworkflow/goldeneggg/structil/ci.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yml:120: update your workflow using https://app.stepsecurity.io/secureworkflow/goldeneggg/structil/ci.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:166: update your workflow using https://app.stepsecurity.io/secureworkflow/goldeneggg/structil/ci.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:209: update your workflow using https://app.stepsecurity.io/secureworkflow/goldeneggg/structil/ci.yml/master?enable=pin","Warn: containerImage not pinned by hash: docker/test/Dockerfile:1: pin your Docker image by updating golang:1.19-alpine to golang:1.19-alpine@sha256:0ec0646e208ea58e5d29e558e39f2e59fccf39b7bda306cb53bbaff91919eca5","Info:   0 out of  13 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   2 third-party GitHubAction dependencies pinned","Info:   0 out of   1 containerImage dependencies pinned","Info:   1 out of   1 goCommand dependencies pinned"],"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":"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":"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":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"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 29 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-19T04:17:21.283Z","repository_id":39261221,"created_at":"2025-08-19T04:17:21.283Z","updated_at":"2025-08-19T04:17:21.283Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29123675,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-05T14:05:12.718Z","status":"ssl_error","status_checked_at":"2026-02-05T14:03:53.078Z","response_time":65,"last_error":"SSL_read: 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":["decoder","go","golang","json","json-parser","structs"],"created_at":"2026-02-05T14:31:28.219Z","updated_at":"2026-02-05T14:31:29.481Z","avatar_url":"https://github.com/goldeneggg.png","language":"Go","readme":"structil [![PkgGoDev](https://pkg.go.dev/badge/github.com/goldeneggg/structil)](https://pkg.go.dev/github.com/goldeneggg/structil)\n==========\n\n[![Workflow Status](https://github.com/goldeneggg/structil/workflows/CI/badge.svg)](https://github.com/goldeneggg/structil/actions)\n[![Go Report Card](https://goreportcard.com/badge/github.com/goldeneggg/structil)](https://goreportcard.com/report/github.com/goldeneggg/structil)\n[![Codecov](https://codecov.io/github/goldeneggg/structil/coverage.svg?branch=master)](https://codecov.io/github/goldeneggg/structil?branch=master)\n[![MIT License](http://img.shields.io/badge/license-MIT-lightgrey.svg)](https://github.com/goldeneggg/structil/blob/master/LICENSE)\n\nstruct + util = __structil__, for runtime and dynamic environment in Go.\n\n\n## Why?\n\nI'd like to ...\n\n- conveniently handle and decode the known or unknown formatted JSON/YAML\n- conveniently dive into the specific field in nested struct\n- simply verify if a field with the specified name and type exists in object\n- etc\n\nwith Go reflection package experimentally.\n\n```\n*** JSON and YAML format is known or unknown ***\n\n\nJSON →→→→→→→→→→→→→→→→↓        →→ (known format)   struct  →→→→→→→→→→→↓→→→ (use struct directly)\n                     ↓        ↑                                      ↓\n                     ↓→→ map →→→ (unknown format) \"DynamicStruct\" →→→→→→ \"Getter\", \"Finder\"\n                     ↑\nYAML →→→→→→→→→→→→→→→→↑\n                     ↑\n(and other formats) →↑\n```\n\nPlease see [my medium post](https://medium.com/@s0k0mata/dynamic-and-runtime-struct-utilities-in-go-go-golang-reflection-25c154335185) as well.\n\n## Sample Usecase\n\nTry printing the struct definition from __the unknown formatted__ JSON decoding.\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/goldeneggg/structil/dynamicstruct/decoder\"\n)\n\nfunc main() {\n\tunknownJSON := []byte(`\n{\n\t\"string_field\":\"かきくけこ\",\n\t\"int_field\":45678,\n\t\"bool_field\":false,\n\t\"object_field\":{\n\t\t\"id\":12,\n\t\t\"name\":\"the name\",\n\t\t\"nested_object_field\": {\n\t\t\t\"address\": \"Tokyo\",\n\t\t\t\"is_manager\": true\n\t\t}\n\t},\n\t\"array_string_field\":[\n\t\t\"array_str_1\",\n\t\t\"array_str_2\"\n\t],\n\t\"array_struct_field\":[\n\t\t{\n\t\t\t\"kkk\":\"kkk1\",\n\t\t\t\"vvvv\":\"vvv1\"\n\t\t},\n\t\t{\n\t\t\t\"kkk\":\"kkk2\",\n\t\t\t\"vvvv\":\"vvv2\"\n\t\t}\n\t],\n\t\"null_field\":null\n}\n`)\n\n  // create `Decoder` from JSON\n  dec, err := decoder.FromJSON(unknownJSON)\n  if err != nil {\n    panic(err)\n  }\n\n  // - If `nest` is true, nested object attributes will be also decoded to struct recursively\n  // - If `nest` is false, nested object attributes will be decoded to `map[string]interface{}`\n  nest := true\n\n  // - If `useTag` is true, JSON Struct tags are defined\n  useTag := true\n\n  // create `DynamicStruct` from `Decoder`\n  ds, err := dec.DynamicStruct(nest, useTag)\n  if err != nil {\n    panic(err)\n  }\n\n  // print struct definition from `DynamicStruct`\n  fmt.Println(ds.Definition())\n}\n```\n\nThis program will print a Go struct definition string as follows.\n\n```go\n// - Type name is \"DynamicStruct\" (raname is available)\n// - Field names are automatically camelized from input json attribute names\n// - Fields are ordered by field name\ntype DynamicStruct struct {\n        ArrayStringField []string `json:\"array_string_field\"`\n        ArrayStructField []struct {\n                Kkk string `json:\"kkk\"`\n                Vvvv string `json:\"vvvv\"`\n        } `json:\"array_struct_field\"`\n        BoolField bool `json:\"bool_field\"`\n        IntField float64 `json:\"int_field\"`\n        NullField interface {} `json:\"null_field\"`\n        ObjectField struct {\n                Id float64 `json:\"id\"`\n                Name string `json:\"name\"`\n                NestedObjectField struct {\n                        Address string `json:\"address\"`\n                        IsManager bool `json:\"is_manager\"`\n                } `json:\"nested_object_field\"`\n        } `json:\"object_field\"`\n        StringField string `json:\"string_field\"`\n}\n```\n\nAnd see [example code](/dynamicstruct/decoder/example_test.go#L9).\n\n## More Examples\n\n### From JSON to `Getter`\n\nWe can convert from __the unknown formatted__ JSON to `Getter` via `DynamicStruct` with `decoder.JSONToGetter` function.\n\nSee [example code](/dynamicstruct/decoder/example_test.go#L76).\n\n#### What is `Getter`?\n\nWe can access a struct using field name string, like (typed) map with `structil.NewGetter` function.\n\n```go\ng, err := structil.NewGetter(structOrStructPointerVariable)\n\n// get num of struct fields\ng.NumField()\n\n// names of struct fields\ng.Names()\n\n// return true if struct has a \"fName\" field\ng.Has(fName)\n\n// get \"fName\" field value of the original struct as string \ng.String(fName)\n\n// return true if \"fName\" field value of the original struct is float64\ng.IsFloat64(fName)\n\n// convert from struct to map[string]interface{}\ng.ToMap()\n\n// get as `Getter` if \"fName\" field is a (nested) struct\ngNest, ok := g.GetGetter(fName)\ngNest.NumField()\ngNest.Names()\n\n```\n\nSee [example code](/example_test.go#L7)\n\n##### `Getter.MapGet` method\n\n`Getter.MapGet` method provides the __Map__ collection function for slice of struct\n\nSee [example code](/example_test.go#L56)\n\n### From JSON to `DynamicStruct`\n\nWe can convert from __the unknown formatted__ JSON to `DynamicStruct` with `Decoder` (from `decoder.FromJSON` function) and `Decoder.DynamicStruct` method.\n\nSee [example code](/dynamicstruct/decoder/example_test.go#L9).\n\n#### What is `DynamicStruct`?\n\nWe can create the dynamic and runtime struct.\n\nSee [example code](/dynamicstruct/example_test.go#L10)\n\n### `Finder`\n\nWe can access usefully nested struct fields using field name string.\n\nSee [example code](/example_test.go#L115)\n\n\n#### With config file? use `FinderKeys`\n\nWe can create a Finder from the configuration file that have some finding target keys. We support some file formats of configuration file such as `yaml`, `json`, `toml` and more.\n\nSee [example code](/example_test.go#L189)\n\n___Thanks for the awesome configuration management library [spf13/viper](https://github.com/spf13/viper).___\n\n\n## Benchmark\n\nSee [this file](https://github.com/goldeneggg/structil/blob/bench-latest/BENCHMARK_LATEST.txt)\n\nIt's the latest benchmark result that is executed on GitHub Actions runner instance.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoldeneggg%2Fstructil","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgoldeneggg%2Fstructil","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoldeneggg%2Fstructil/lists"}