{"id":36860193,"url":"https://github.com/usvc/go-config","last_synced_at":"2026-01-12T14:49:25.207Z","repository":{"id":57515221,"uuid":"243909248","full_name":"usvc/go-config","owner":"usvc","description":"A Go package to deal with configuration","archived":false,"fork":false,"pushed_at":"2021-02-14T16:50:43.000Z","size":133,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-15T22:04:26.026Z","etag":null,"topics":["cobra","configuration","go","go-library","go-module","go-package","viper"],"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/usvc.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":"2020-02-29T05:17:12.000Z","updated_at":"2023-04-18T13:18:52.000Z","dependencies_parsed_at":"2022-08-28T16:51:17.328Z","dependency_job_id":null,"html_url":"https://github.com/usvc/go-config","commit_stats":null,"previous_names":["usvc/config"],"tags_count":44,"template":false,"template_full_name":null,"purl":"pkg:github/usvc/go-config","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/usvc%2Fgo-config","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/usvc%2Fgo-config/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/usvc%2Fgo-config/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/usvc%2Fgo-config/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/usvc","download_url":"https://codeload.github.com/usvc/go-config/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/usvc%2Fgo-config/sbom","scorecard":{"id":912910,"data":{"date":"2025-08-11","repo":{"name":"github.com/usvc/go-config","commit":"152dcb7f137a7ade52872c698fd9cb71ca2ec2af"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.5,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/30 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":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"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":"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":"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":-1,"reason":"no workflows found","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":"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":"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":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: containerImage not pinned by hash: deploy/Dockerfile:1","Warn: containerImage not pinned by hash: deploy/Dockerfile:11: pin your Docker image by updating gcr.io/distroless/base-debian10 to gcr.io/distroless/base-debian10@sha256:101798a3b76599762d3528635113f0466dc9655ecba82e8e33d410e2bf5cd319","Info:   0 out of   2 containerImage 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":"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":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"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":"Signed-Releases","score":0,"reason":"Project has not signed or included provenance with any releases.","details":["Warn: release artifact v0.4.1 not signed: https://api.github.com/repos/usvc/go-config/releases/38032235","Warn: release artifact v0.4.0 not signed: https://api.github.com/repos/usvc/go-config/releases/38023990","Warn: release artifact v0.3.1 not signed: https://api.github.com/repos/usvc/go-config/releases/38005839","Warn: release artifact v0.3.0 not signed: https://api.github.com/repos/usvc/go-config/releases/38005062","Warn: release artifact v0.2.5 not signed: https://api.github.com/repos/usvc/go-config/releases/37538049","Warn: release artifact v0.4.1 does not have provenance: https://api.github.com/repos/usvc/go-config/releases/38032235","Warn: release artifact v0.4.0 does not have provenance: https://api.github.com/repos/usvc/go-config/releases/38023990","Warn: release artifact v0.3.1 does not have provenance: https://api.github.com/repos/usvc/go-config/releases/38005839","Warn: release artifact v0.3.0 does not have provenance: https://api.github.com/repos/usvc/go-config/releases/38005062","Warn: release artifact v0.2.5 does not have provenance: https://api.github.com/repos/usvc/go-config/releases/37538049"],"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"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-24T19:54:32.733Z","repository_id":57515221,"created_at":"2025-08-24T19:54:32.734Z","updated_at":"2025-08-24T19:54:32.734Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28340410,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-12T12:22:26.515Z","status":"ssl_error","status_checked_at":"2026-01-12T12:22:10.856Z","response_time":98,"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":["cobra","configuration","go","go-library","go-module","go-package","viper"],"created_at":"2026-01-12T14:49:25.110Z","updated_at":"2026-01-12T14:49:25.187Z","avatar_url":"https://github.com/usvc.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Config\n\n[![release github](https://badge.fury.io/gh/usvc%2Fgo-config.svg)](https://github.com/usvc/go-config/releases)\n[![build status](https://travis-ci.org/usvc/go-config.svg?branch=master)](https://travis-ci.org/usvc/go-config)\n[![pipeline status](https://gitlab.com/usvc/modules/go/config/badges/master/pipeline.svg)](https://gitlab.com/usvc/modules/go/config/-/commits/master)\n[![Test Coverage](https://api.codeclimate.com/v1/badges/aa75f20cdfd8f0d5785b/test_coverage)](https://codeclimate.com/github/usvc/go-config/test_coverage)\n[![Maintainability](https://api.codeclimate.com/v1/badges/aa75f20cdfd8f0d5785b/maintainability)](https://codeclimate.com/github/usvc/go-config/maintainability)\n\nA Go package to deal with configuration.\n\n| | |\n| --- | --- |\n| Github | [https://github.com/usvc/go-config](https://github.com/usvc/go-config) |\n| Gitlab | [https://gitlab.com/usvc/modules/go/config](https://gitlab.com/usvc/modules/go/config) |\n\n- - -\n\n- [Config](#config)\n\t- [Usage](#usage)\n\t\t- [Importing](#importing)\n\t\t- [Defining configuration](#defining-configuration)\n\t\t- [Consuming from environment](#consuming-from-environment)\n\t\t- [Applying to Cobra (`github.com/spf13/cobra` package)](#applying-to-cobra-githubcomspf13cobra-package)\n\t\t- [Retrieving values frrom the configuration](#retrieving-values-frrom-the-configuration)\n\t\t- [Note on `*`Slice types](#note-on-slice-types)\n\t\t- [Note on configuration names](#note-on-configuration-names)\n\t- [Example CLI Application](#example-cli-application)\n\t- [Development Runbook](#development-runbook)\n\t\t- [Getting Started](#getting-started)\n\t\t- [Continuous Integration (CI) Pipeline](#continuous-integration-ci-pipeline)\n\t\t\t- [On Github](#on-github)\n\t\t\t\t- [Releasing](#releasing)\n\t\t\t- [On Gitlab](#on-gitlab)\n\t\t\t\t- [Version Bumping](#version-bumping)\n\t\t\t\t- [DockerHub Publishing](#dockerhub-publishing)\n\t- [Licensing](#licensing)\n\n## Usage\n\n### Importing\n\n```go\nimport \"github.com/usvc/go-config\"\n```\n\n### Defining configuration\n\nFollowing example can also be found at [`./cmd/config/config.go`](./cmd/config/config.go)\n\n```go\nvar conf = config.Map{\n\t// with env : BOOL=true\n\t// with flag: --bool | -b\n\t\"bool\": \u0026config.Bool{\n\t\tDefault:   false,\n\t\tShorthand: \"b\",\n\t\tUsage:     \"specifies a boolean value\",\n\t},\n\t// with env : FLOAT=-123\n\t// with flag: --float -123 | -f -123\n\t\"float\": \u0026config.Float{\n\t\tDefault:   1.6180339887498948482045868343,\n\t\tShorthand: \"f\",\n\t\tUsage:     \"specifies a floating point value\",\n\t},\n\t// with env : INT=-123\n\t// with flag: --int -123 | -i -123\n\t\"int\": \u0026config.Int{\n\t\tDefault:   -1,\n\t\tShorthand: \"i\",\n\t\tUsage:     \"specifies a signed integer value\",\n\t},\n\t// with env : INTS=\"-123 -456\"\n\t// with flag: --int-slice -123,-456 | -I -123,-456\n\t\"int slice\": \u0026config.IntSlice{\n\t\tDefault:   []int{-2, -3},\n\t\tShorthand: \"I\",\n\t\tUsage:     \"specifies a slice of signed integers value\",\n\t},\n\t// with env : STRING=value\n\t// with flag: --string value | -s value\n\t\"string\": \u0026config.String{\n\t\tDefault:   \"default\",\n\t\tShorthand: \"s\",\n\t\tUsage:     \"specifies a string value\",\n\t},\n\t// with env : STRING_SLICE=\"value1 value2\"\n\t// with flag: --string-slice value1,value2 | -S value1,value2\n\t\"string slice\": \u0026config.StringSlice{\n\t\tDefault:   []string{\"hello\", \"world\"},\n\t\tShorthand: \"S\",\n\t\tUsage:     \"specifies a slice of strings value\",\n\t},\n\t// with env : UINT=123\n\t// with flag: --uint 123 | -u 123\n\t\"uint\": \u0026config.Uint{\n\t\tDefault:   1,\n\t\tShorthand: \"u\",\n\t\tUsage:     \"specifies an unsigned integer value\",\n\t},\n}\n```\n\n### Consuming from environment\n\n\u003e Following example assumes the above `conf` variable was defined.\n\n```go\nconf.LoadFromEnvironment()\n```\n\n### Applying to Cobra (`github.com/spf13/cobra` package)\n\n\u003e Following example assumes the above `conf` variable was defined.\n\n```go\ncmd := cobra.Command { /* ... config ... */ }\n/* ... everything else ... */\nconf.ApplyToCobra(\u0026cmd)\n// OR\nconf.ApplyToCobraPersistent(\u0026cmd)\ncmd.Execute()\n```\n\nWhen using `conf.ApplyToCobra()` or `conf.ApplyToCobraPersistent()`, **the flag takes priority** if the equivalent environment variable was also defined. This is the behaviour since 0.2.5.\n\n### Retrieving values frrom the configuration\n\n\u003e Following example assumes the above `conf` variable was defined.\n\n```go\nfmt.Println(\"bool         : %v\", conf.GetBool(\"bool\"))\nfmt.Println(\"float        : %v\", conf.GetFloat(\"float\"))\nfmt.Println(\"int          : %v\", conf.GetInt(\"int\"))\nfmt.Println(\"int slice    : %v\", conf.GetIntSlice(\"int slice\"))\nfmt.Println(\"string       : %s\", conf.GetString(\"string\"))\nfmt.Println(\"string slice : %v\", conf.GetStringSlice(\"string slice\"))\nfmt.Println(\"uint         : %v\", conf.GetUint(\"uint\"))\n```\n\nIf you've applied the above `config.Map` instance to Cobra, running the following:\n\n```sh\ngo run ./cmd/config \\\n\t--bool=true \\\n\t--float 3.142 \\\n\t--int 1 \\\n\t--int-slice 1,-2,3,-4,5 \\\n\t--string a \\\n\t--string-slice a,b,c,d,e \\\n\t--uint 1\n```\n\nShould result in the following output:\n\n```\nuint: 1\nbool: true\nfloat: 3.142\nint: 1\nint slice: [1 -2 3 -4 5] (length: 5)\nstring: a\nstring slice: [a b c d e] (length: 5)\n```\n\nIf you ran the following:\n\n```sh\n\n```\n\n\n### Note on `*`Slice types\n\nFor the slice types (`IntSlice`, `StringSlice`), the delimiter is a comma (`,`) despite the underlying package (`github.com/spf13/viper`) handling the splitting a little differently. A tiny hack (famous last words: sorry, me-in-2025) was made to parse these using commas instead of spaces.\n\n### Note on configuration names\n\nThe `config.Map` is used to define a dictionary of your configuration values using a `map[string]config.Config` data structure. The `string` becomes the name of the configuration and this `string` is manipulated before being passed to the downstream library.\n\nFor environment variables, all non-alphanumeric characters will be converted to an underscore (`_`), and all alphabetic characters will be converted to `UPPERCASE_IN_SNAKE_CASE`.\n\nFor flags, all non-alphanumeric characters will be converted to a hypen (`-`), and all alphabetic characters will be converted to `lowercase-in-kebab-case`.\n\n## Example CLI Application\n\nThe example CLI application can be found in the [`./cmd/config` directory](./cmd/config) and includes the configuration as found above. To test it out you can run the following:\n\n```sh\n# bool\ngo run ./cmd/config --bool\nBOOL=1 go run ./cmd/config\n\n# float\ngo run ./cmd/config --float 3.142\nFLOAT=3.142 go run ./cmd/config\n\n# int\ngo run ./cmd/config --int -12345\nINT=-12345 go run ./cmd/config\n\n# []int\ngo run ./cmd/config --int-slice -12345 --int-slice -67890\nINT_SLICE=\"-12345 -67890\" go run ./cmd/config\n\n# string\ngo run ./cmd/config --string \"hello world\"\nSTRING=\"hello world\" go run ./cmd/config\n\n# []string\ngo run ./cmd/config --string-slice \"hello\" --string-slice \"world\"\nSTRING_SLICE=\"hello world\" go run ./cmd/config\n\n# uint\ngo run ./cmd/config --uint 12345\nUINT=12345 go run ./cmd/config\n```\n\n## Development Runbook\n\n### Getting Started\n\n1. Clone this repository\n2. Run `make deps` to pull in external dependencies\n3. Write some awesome stuff\n4. Run `make test` to ensure unit tests are passing\n5. Push\n\n### Continuous Integration (CI) Pipeline\n\n#### On Github\n\nGithub is used to deploy binaries/libraries because of it's ease of access by other developers.\n\n##### Releasing\n\nReleasing of the binaries can be done via Travis CI.\n\n1. On Github, navigate to the [tokens settings page](https://github.com/settings/tokens) (by clicking on your profile picture, selecting **Settings**, selecting **Developer settings** on the left navigation menu, then **Personal Access Tokens** again on the left navigation menu)\n2. Click on **Generate new token**, give the token an appropriate name and check the checkbox on **`public_repo`** within the **repo** header\n3. Copy the generated token\n4. Navigate to [travis-ci.org](https://travis-ci.org) and access the cooresponding repository there. Click on the **More options** button on the top right of the repository page and select **Settings**\n5. Scroll down to the section on **Environment Variables** and enter in a new **NAME** with `RELEASE_TOKEN` and the **VALUE** field cooresponding to the generated personal access token, and hit **Add**\n\n#### On Gitlab\n\nGitlab is used to run tests and ensure that builds run correctly.\n\n##### Version Bumping\n\n1. Run `make .ssh`\n2. Copy the contents of the file generated at `./.ssh/id_rsa.base64` into an environment variable named **`DEPLOY_KEY`** in **Settings \u003e CI/CD \u003e Variables**\n3. Navigate to the **Deploy Keys** section of the **Settings \u003e Repository \u003e Deploy Keys** and paste in the contents of the file generated at `./.ssh/id_rsa.pub` with the **Write access allowed** checkbox enabled\n\n- **`DEPLOY_KEY`**: generate this by running `make .ssh` and copying the contents of the file generated at `./.ssh/id_rsa.base64`\n\n##### DockerHub Publishing\n\n1. Login to [https://hub.docker.com](https://hub.docker.com), or if you're using your own private one, log into yours\n2. Navigate to [your security settings at the `/settings/security` endpoint](https://hub.docker.com/settings/security)\n3. Click on **Create Access Token**, type in a name for the new token, and click on **Create**\n4. Copy the generated token that will be displayed on the screen\n5. Enter the following varialbes into the CI/CD Variables page at **Settings \u003e CI/CD \u003e Variables** in your Gitlab repository:\n\n- **`DOCKER_REGISTRY_URL`**: The hostname of the Docker registry (defaults to `docker.io` if not specified)\n- **`DOCKER_REGISTRY_USERNAME`**: The username you used to login to the Docker registry\n- **`DOCKER_REGISTRY_PASSWORD`**: The generated access token\n\n## Licensing\n\nCode in this package is licensed under the [MIT license (click to see full text))](./LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fusvc%2Fgo-config","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fusvc%2Fgo-config","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fusvc%2Fgo-config/lists"}