{"id":44880682,"url":"https://github.com/corpix/flatstructs","last_synced_at":"2026-02-17T16:04:46.618Z","repository":{"id":57510557,"uuid":"83287230","full_name":"corpix/flatstructs","owner":"corpix","description":"Provides helpers to flatten nested structures in go","archived":false,"fork":false,"pushed_at":"2018-03-21T22:01:21.000Z","size":151,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-08-15T04:42:23.046Z","etag":null,"topics":["go-packages","golang","structs"],"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/corpix.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}},"created_at":"2017-02-27T08:35:28.000Z","updated_at":"2018-10-22T17:20:27.000Z","dependencies_parsed_at":"2022-09-26T16:31:09.094Z","dependency_job_id":null,"html_url":"https://github.com/corpix/flatstructs","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/corpix/flatstructs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/corpix%2Fflatstructs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/corpix%2Fflatstructs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/corpix%2Fflatstructs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/corpix%2Fflatstructs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/corpix","download_url":"https://codeload.github.com/corpix/flatstructs/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/corpix%2Fflatstructs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29549244,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-17T14:33:00.708Z","status":"ssl_error","status_checked_at":"2026-02-17T14:32:58.657Z","response_time":100,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: 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":["go-packages","golang","structs"],"created_at":"2026-02-17T16:04:45.732Z","updated_at":"2026-02-17T16:04:46.609Z","avatar_url":"https://github.com/corpix.png","language":"Go","readme":"flatstructs\n-----------\n\n[![Build Status](https://travis-ci.org/corpix/flatstructs.svg?branch=master)](https://travis-ci.org/corpix/flatstructs)\n\nProvides helpers to flatten nested structures in go.\n\n## Example\n\n``` go\npackage main\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/corpix/flatstructs\"\n)\n\ntype Scope struct {\n\tRequest\n\tConnection\n}\n\ntype Request struct {\n\tHeaders\n}\n\ntype Headers struct {\n\tUserAgent string\n\tReferer   string\n}\n\ntype Connection struct {\n\tHost string\n\tPort int\n}\n\ntype Event struct {\n\tID     int\n\tSource string\n\tScope\n}\n\nfunc main() {\n\tevent := \u0026Event{\n\t\tID:     1,\n\t\tSource: \"system\",\n\t\tScope: Scope{\n\t\t\tRequest: Request{\n\t\t\t\tHeaders: Headers{\n\t\t\t\t\tUserAgent: \"curl\",\n\t\t\t\t\tReferer:   \"http://example.com\",\n\t\t\t\t},\n\t\t\t},\n\t\t\tConnection: Connection{\n\t\t\t\tHost: \"127.0.0.1\",\n\t\t\t\tPort: 1337,\n\t\t\t},\n\t\t},\n\t}\n\n\tkeys, err := flatstructs.Keys(event)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tvalues, err := flatstructs.Values(event)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(\"flatstructs.Keys(event) -\u003e \", keys)\n\tfmt.Println(\"flatstructs.Values(event) -\u003e \", values)\n}\n```\n\nNow save this code into `snippet.go` and:\n\n``` shell\ngo run ./snippet.go\nflatstructs.Keys(event) -\u003e  [ID Source ScopeRequestHeadersUserAgent ScopeRequestHeadersReferer ScopeConnectionHost ScopeConnectionPort]\nflatstructs.Values(event) -\u003e  [1 system curl http://example.com 127.0.0.1 1337]\n```\n\n## Limitations\n\n\u003e Some of them are not limitations actually but it is worth to mention them here.\n\n* If getting `Values()` and somewhere in the chain there is a slice of `struct`'s it will be returned untouched\n* Map's is also returned untouched when getting `Values()` and `Keys()` is not going inside map's\n\n## Customization\n\n### Builder\n\nThere is things you could customize:\n\n* Key delimiter\n* Key name\n* Key tag name\n\nThis customization's are available via custom `Builder`:\n\n``` go\nbuilder := flatstructs.NewBuilder(\"key\", \".\")\n\nbuilder.Keys(...)\nbuilder.Values(...)\nbuilder.Map(...)\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcorpix%2Fflatstructs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcorpix%2Fflatstructs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcorpix%2Fflatstructs/lists"}