{"id":45093970,"url":"https://github.com/lzambarda/goflat","last_synced_at":"2026-02-19T18:05:49.885Z","repository":{"id":266873062,"uuid":"894431966","full_name":"lzambarda/goflat","owner":"lzambarda","description":"Context-aware generic CSV marshaller/unmarshaller","archived":false,"fork":false,"pushed_at":"2025-09-13T13:48:33.000Z","size":36,"stargazers_count":11,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-09-13T15:44:22.493Z","etag":null,"topics":["csv","go","marshaller","unmarshaller"],"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/lzambarda.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-11-26T10:50:07.000Z","updated_at":"2025-09-13T13:44:53.000Z","dependencies_parsed_at":null,"dependency_job_id":"fb51b0ad-2eb8-484c-a107-ba69d75aaaba","html_url":"https://github.com/lzambarda/goflat","commit_stats":null,"previous_names":["lzambarda/goflat"],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/lzambarda/goflat","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lzambarda%2Fgoflat","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lzambarda%2Fgoflat/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lzambarda%2Fgoflat/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lzambarda%2Fgoflat/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lzambarda","download_url":"https://codeload.github.com/lzambarda/goflat/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lzambarda%2Fgoflat/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29626692,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-19T18:02:07.722Z","status":"ssl_error","status_checked_at":"2026-02-19T18:01:46.144Z","response_time":117,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6: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":["csv","go","marshaller","unmarshaller"],"created_at":"2026-02-19T18:05:49.242Z","updated_at":"2026-02-19T18:05:49.878Z","avatar_url":"https://github.com/lzambarda.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# goflat\n![Coverage](https://img.shields.io/badge/Coverage-81.3%25-brightgreen)\n\n[![Go Reference](https://pkg.go.dev/badge/github.com/lzambarda/goflat.svg)](https://pkg.go.dev/github.com/lzambarda/goflat)\n[![Go Report Card](https://goreportcard.com/badge/github.com/lzambarda/goflat)](https://goreportcard.com/report/github.com/lzambarda/goflat)\n\nGeneric, context-aware flat file marshaller and unmarshaller using the `flat` field tag in structs.\n\n## Overview\n\n```go\ntype Record struct {\n    FirstName string  `flat:\"first_name\"`\n    LastName  *string `flat:\"last_name\"`\n    Age       int     `flat:\"age\"`\n    Height    float32 `flat:\"-\"` // ignored\n}\n\n...\n\ngoflat.MarshalIteratorToWriter[Record](ctx, seq, writer *csv.Writer, opts Options)\n\n// or\n\ngoflat.MarshalSliceToWriter[Record](ctx, slice, csvWriter, options)\n\n// or\n\ngoflat.MarshalChannelToWriter[Record](ctx, inputCh, csvWriter, options)\n\n```\n\nWill result in:\n\n```\nfirst_name,last_name,age\nJohn,Doe,30\nJane,Doe,20\n```\n\nCan unmarshal too!\n\n```go\ngoflat.UnmarshalToChan[Record](ctx, csvReader, options, outputCh)\n```\n\n## Options\n\nBoth marshal and unmarshal operations support `goflat.Options`, which allow to introduce automatic safety checks, such as duplicated headers, `flat` tag coverage and more.\n\n## Custom marshal / unmarshal\n\nBoth operations can be customised for each field in a struct by having that value implementing `goflat.Marshal` and/or `goflat.Unmarshal`.\n\n```go\ntype Record struct {\n    Field MyType `flat:\"field\"`\n}\n\ntype MyType struct {\n    Value int\n}\n\nfunc (m *MyType) Marshal() (string,error) {\n    if m.Value %2 == 0 {\n        return \"odd\", nil\n    }\n\n    return \"even\", nil\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flzambarda%2Fgoflat","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flzambarda%2Fgoflat","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flzambarda%2Fgoflat/lists"}