{"id":22018122,"url":"https://github.com/rvflash/genum","last_synced_at":"2026-05-15T22:37:56.836Z","repository":{"id":57597967,"uuid":"378463301","full_name":"rvflash/genum","owner":"rvflash","description":"An enum generator for go based on CSV data","archived":false,"fork":false,"pushed_at":"2021-07-20T21:21:08.000Z","size":66,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-07T20:43:45.119Z","etag":null,"topics":[],"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/rvflash.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":"2021-06-19T17:01:17.000Z","updated_at":"2021-08-04T07:50:00.000Z","dependencies_parsed_at":"2022-08-28T09:11:56.188Z","dependency_job_id":null,"html_url":"https://github.com/rvflash/genum","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/rvflash/genum","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rvflash%2Fgenum","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rvflash%2Fgenum/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rvflash%2Fgenum/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rvflash%2Fgenum/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rvflash","download_url":"https://codeload.github.com/rvflash/genum/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rvflash%2Fgenum/sbom","scorecard":{"id":791116,"data":{"date":"2025-08-11","repo":{"name":"github.com/rvflash/genum","commit":"68323b49b1e6d9bb0bc6f067d091ba38ec0846e6"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.4,"checks":[{"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":"Code-Review","score":0,"reason":"Found 0/15 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":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":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/go-build.yml:14: update your workflow using https://app.stepsecurity.io/secureworkflow/rvflash/genum/go-build.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/go-build.yml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/rvflash/genum/go-build.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/go-build.yml:33: update your workflow using https://app.stepsecurity.io/secureworkflow/rvflash/genum/go-build.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/go-build.yml:37: update your workflow using https://app.stepsecurity.io/secureworkflow/rvflash/genum/go-build.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/golangci-lint.yml:14: update your workflow using https://app.stepsecurity.io/secureworkflow/rvflash/genum/golangci-lint.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/golangci-lint.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/rvflash/genum/golangci-lint.yml/main?enable=pin","Warn: downloadThenRun not pinned by hash: .github/workflows/go-build.yml:24","Info:   0 out of   5 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   1 third-party GitHubAction dependencies pinned","Info:   0 out of   1 downloadThenRun 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":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/go-build.yml:1","Warn: no topLevel permission defined: .github/workflows/golangci-lint.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":"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: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":"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 'main'"],"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":"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-23T07:35:12.763Z","repository_id":57597967,"created_at":"2025-08-23T07:35:12.763Z","updated_at":"2025-08-23T07:35:12.763Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33082136,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-15T20:25:35.270Z","status":"ssl_error","status_checked_at":"2026-05-15T20:25:34.732Z","response_time":103,"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":[],"created_at":"2024-11-30T05:10:00.537Z","updated_at":"2026-05-15T22:37:56.821Z","avatar_url":"https://github.com/rvflash.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Genum\n\n[![GoDoc](https://godoc.org/github.com/rvflash/genum?status.svg)](https://godoc.org/github.com/rvflash/genum)\n[![Build Status](https://github.com/rvflash/genum/workflows/build/badge.svg)](https://github.com/rvflash/genum/actions?workflow=build)\n[![Code Coverage](https://codecov.io/gh/rvflash/genum/branch/main/graph/badge.svg)](https://codecov.io/gh/rvflash/genum)\n[![Go Report Card](https://goreportcard.com/badge/github.com/rvflash/genum)](https://goreportcard.com/report/github.com/rvflash/genum)\n\n`genum` parses comma-separated values (CSV) from a file, or the standard input by default to automate \nthe generation of a Go file, where data becoming constant names and/or values of an enum type.\n\nGiven a name of a (signed or unsigned) integer, a float or a string type T and a package name, \n`genum` will create a new self-contained Go source file, named by default `\u003cT\u003e.go` with only constant values.\n\nEach CSV line is a new constant, where the first column is the name, and/or the value, depending on the settings, \nand the second if provided, is the value.   \n\n\n## Features\n\n* No check is made and records may have a variable number of fields. So we do not need to specify all values, \n  even names. `_` is used as default constant name.\n* Support of the following types: int, int8, int16, int32, int64, uint, uint8, uint16, uint32, uint64, float32, \n  float64 and string.\n* Iota to simplify the code but values from the CVS force the iota to adapt.\n* Bitmask to use one integer to hold multiple flags and provide bitwise operations.\n* The `String` method can return more than the name of the constant, using the `string_formater` \n  you can format a value based on the enum name, value and type.\n* Add comment on any constant declaration with its value.\n\nSee the [examples](examples/) for more use cases.\n\nUsing `genum` flags, you can add implementation of the following interfaces:\n\n* fmt.Stringer with customized output, see formatting options to format the return based on enum type, name or value:\n```go\n    func (e T) String() string\n```\n* encoding.TextMarshaler / encoding.TextUnmarshaler\n```go\n    func (e T) MarshalText() (text []byte, err error)\n    func (e *T) UnmarshalText(text []byte) error\n```\n* json.Marshaler / json.Unmarshaler\n```go\n    func (e T) MarshalJSON() ([]byte, error)\n    func (e *T) UnmarshalJSON([]byte) error\n```\n* xml.Marshaler / xml.Unmarshaler\n```go\n    func (e T) MarshalXML(e *Encoder, start StartElement) error\n    func (e *T) UnmarshalXML(d *Decoder, start StartElement) error\n```\n\nOr methods:\n\n* `IsValid` checks the validity of a constant.\n```go\n    func (e T) IsValid() bool\n```\n\nOr with bitmask enabled, these methods provide bitwise operations:\n\n```go \n    // Has returns in success if this bitmask has this flag.\n    func (e T) Has(e2 T) bool\n    // Set sets this bitflag.\n    func (e *T) Set(e2 T) bool\n    // Switch only changes the bitflag if necessary. It returns true if the requested action has been done.\n    func (e *T) Switch(e2 T, on bool) (done bool)\n    // Toggle toggles this bitflag.\n    func (e *T) Toggle(e2 T) \n    // Unset clears this bitflag.\n    func (e *T) Unset(e2 T) \n```\n\nTypically, this process would be run using the `go generate ./...` command, like this:\n\n```go\n//go:generate genum -pkg ${GOPACKAGE} -type hi values.csv\n```\n\n\n## Demo\n\nThe command `echo -e \"hello\\nbonjour\\nguten morgen\\nhola\" | genum -pkg say -name hi` will generate the file `./hi.go`:\n\n```go\n// Code generated by \"genum -pkg say -type hi\"; DO NOT EDIT.\n\npackage say\n\n// Hi is an enum.\ntype Hi int\n\n// List of known Hi enums.\nconst (\n\tHello Hi = iota\n\tBonjour\n\tGutenMorgen\n\tHola\n)\n\n```\n\n\n### Installation\n\n```shell\nGO111MODULE=on go install github.com/rvflash/genum@latest\n```\n\n\n## Usage\n\n```shell\ngenum [flags] [file]\n```\n\nThe `genum` command generates a Go file based on the CSV values given in input (file path or standard input).\nIt supports the following flags:\n\n    * `-pkg`: package name\n    * `-name`: enum type name (default \"Enum\")\n    * `-type`: enum base type (default \"int\")\n    * `-iota`: declare sequentially growing numeric constants (default true)\n    * `-output`: output file name; default dst_dir/\u003csnake_type\u003e.go\n    * `-stringer`: implement the fmt.Stringer interface\n    * `-stringer_format` format used as returned value by the fmt.Stringer method (default only the enum name: \"%[1]s\"):\n        [1] represents the enum name\n        [2] represents the enum value\n        [3] represents the enum type\n    * `-noprefix`: trim the type name from the generated constant names\n    * `-prefix`: add the type name as prefix of each generated constant names\n    * `-json`: implement the json.Marshaler and json.Unmarshaler interfaces\n    * `-text`: implement the encoding.TextMarshaler and encoding.TextUnmarshaler interfaces\n    * `-xml`: implement the xml.Marshaler and xml.Unmarshaler interfaces\n    * `-comment`: add in comment the values of generated constants\n    * `-validator`: add a method \"IsValid\" to verify the set up of the constant\n    * `-bitmask`: use one integer to hold multiple flags, provide bitwise operations and overwrite the enum base type with unsigned integer type (size in bits based on the number of values)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frvflash%2Fgenum","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frvflash%2Fgenum","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frvflash%2Fgenum/lists"}