{"id":15678147,"url":"https://github.com/nikolaydubina/go-enum-encoding","last_synced_at":"2025-05-07T02:43:56.189Z","repository":{"id":228714874,"uuid":"774704078","full_name":"nikolaydubina/go-enum-encoding","owner":"nikolaydubina","description":"Generate Go enum encoding","archived":false,"fork":false,"pushed_at":"2025-03-14T06:37:26.000Z","size":1923,"stargazers_count":14,"open_issues_count":1,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-31T05:33:10.438Z","etag":null,"topics":["code-generation","encoding","enum","json","serde"],"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/nikolaydubina.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"nikolaydubina"}},"created_at":"2024-03-20T02:47:21.000Z","updated_at":"2025-03-14T06:37:29.000Z","dependencies_parsed_at":"2024-06-21T07:32:10.096Z","dependency_job_id":"dbc157ae-f320-43f0-a166-1b534e838e27","html_url":"https://github.com/nikolaydubina/go-enum-encoding","commit_stats":null,"previous_names":["nikolaydubina/go-enum-encoding"],"tags_count":32,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikolaydubina%2Fgo-enum-encoding","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikolaydubina%2Fgo-enum-encoding/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikolaydubina%2Fgo-enum-encoding/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikolaydubina%2Fgo-enum-encoding/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nikolaydubina","download_url":"https://codeload.github.com/nikolaydubina/go-enum-encoding/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252802629,"owners_count":21806545,"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":["code-generation","encoding","enum","json","serde"],"created_at":"2024-10-03T16:17:42.751Z","updated_at":"2025-05-07T02:43:56.165Z","avatar_url":"https://github.com/nikolaydubina.png","language":"Go","funding_links":["https://github.com/sponsors/nikolaydubina"],"categories":["发电机","Recently Updated","Generators"],"sub_categories":["检索及分析资料库","[Dec 24, 2024](/content/2024/12/24/README.md)","Search and Analytic Databases"],"readme":"# go-enum-encoding\n\n[![Go Report Card](https://goreportcard.com/badge/github.com/nikolaydubina/go-enum-encoding)](https://goreportcard.com/report/github.com/nikolaydubina/go-enum-encoding)\n[![Go Reference](https://pkg.go.dev/badge/github.com/nikolaydubina/go-enum-encoding.svg)](https://pkg.go.dev/github.com/nikolaydubina/go-enum-encoding)\n[![codecov](https://codecov.io/gh/nikolaydubina/go-enum-encoding/graph/badge.svg?token=asZfIddrLV)](https://codecov.io/gh/nikolaydubina/go-enum-encoding)\n[![go-recipes](https://raw.githubusercontent.com/nikolaydubina/go-recipes/main/badge.svg?raw=true)](https://github.com/nikolaydubina/go-recipes)\n[![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/nikolaydubina/go-enum-encoding/badge)](https://securityscorecards.dev/viewer/?uri=github.com/nikolaydubina/go-enum-encoding)\n\n```bash\ngo install github.com/nikolaydubina/go-enum-encoding@latest\n```\n\n* 200 LOC\n* simple, fast, strict\n* generate encoding/decoding, tests, benchmarks\n\n```go\ntype Color struct{ c uint8 }\n\n//go:generate go-enum-encoding -type=Color\nvar (\n\tUndefinedColor = Color{} \t// json:\"\"\n\tRed            = Color{1}\t// json:\"red\"\n\tGreen          = Color{2}\t// json:\"green\"\n\tBlue           = Color{3}\t// json:\"blue\"\n)\n```\n\n`iota` is ok too\n\n```go\ntype Size uint8\n\n//go:generate go-enum-encoding -type=Size\nconst (\n\tUndefinedSize Size = iota // json:\"\"\n\tSmall                     // json:\"small\"\n\tLarge                     // json:\"large\"\n\tXLarge                    // json:\"xlarge\"\n)\n```\n\ngenerated benchmarks\n\n```bash\n$ go test -bench=. -benchmem .                  \ngoos: darwin\ngoarch: arm64\npkg: github.com/nikolaydubina/go-enum-encoding/internal/testdata\ncpu: Apple M3 Max\nBenchmarkColor_UnmarshalText-16         752573839                1.374 ns/op           0 B/op          0 allocs/op\nBenchmarkColor_AppendText-16            450123993                2.676 ns/op           0 B/op          0 allocs/op\nBenchmarkColor_MarshalText-16           80059376                13.68 ns/op            8 B/op          1 allocs/op\nBenchmarkImageSize_UnmarshalText-16     751743885                1.601 ns/op           0 B/op          0 allocs/op\nBenchmarkImageSize_AppendText-16        500286883                2.402 ns/op           0 B/op          0 allocs/op\nBenchmarkImageSize_MarshalText-16       81467318                16.46 ns/op            8 B/op          1 allocs/op\nBenchmarkImageSize_String-16            856463289                1.330 ns/op           0 B/op          0 allocs/op\nPASS\nok      github.com/nikolaydubina/go-enum-encoding/internal/testdata     8.561s\n```\n\n## References\n\n- http://github.com/zarldev/goenums - does much more advanced struct generation, generates all enum utilities besides encoding, does not generate tests, uses similar notation to trigger go:generate but with different comment directives (non-json field tags)\n- http://github.com/nikolaydubina/go-enum-example\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnikolaydubina%2Fgo-enum-encoding","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnikolaydubina%2Fgo-enum-encoding","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnikolaydubina%2Fgo-enum-encoding/lists"}