{"id":23312465,"url":"https://github.com/attumm/settingo","last_synced_at":"2026-02-19T21:52:17.679Z","repository":{"id":47924471,"uuid":"371369664","full_name":"Attumm/settingo","owner":"Attumm","description":"Golang settings should be simple, boring and forget-able. With settingo it will be just that.","archived":false,"fork":false,"pushed_at":"2025-03-12T18:30:32.000Z","size":55,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-03T18:15:57.778Z","etag":null,"topics":["cli","cli-parameters","config","configuration","environment","environment-variables","golang","golang-library","golang-package","setting","settings","settings-management"],"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/Attumm.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-05-27T12:43:13.000Z","updated_at":"2025-03-12T18:30:36.000Z","dependencies_parsed_at":"2024-02-10T11:32:39.885Z","dependency_job_id":"69e5d084-2584-4b97-a319-a5c4d1e4bfd3","html_url":"https://github.com/Attumm/settingo","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/Attumm/settingo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Attumm%2Fsettingo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Attumm%2Fsettingo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Attumm%2Fsettingo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Attumm%2Fsettingo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Attumm","download_url":"https://codeload.github.com/Attumm/settingo/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Attumm%2Fsettingo/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271652314,"owners_count":24797043,"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","status":"online","status_checked_at":"2025-08-22T02:00:08.480Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["cli","cli-parameters","config","configuration","environment","environment-variables","golang","golang-library","golang-package","setting","settings","settings-management"],"created_at":"2024-12-20T14:32:52.109Z","updated_at":"2026-02-19T21:52:17.638Z","avatar_url":"https://github.com/Attumm.png","language":"Go","readme":"# Settingo\n[![GitHub release](https://img.shields.io/github/v/release/Attumm/settingo?sort=semver)](https://github.com/Attumm/settingo/releases/latest)\n[![Go Report Card](https://goreportcard.com/badge/github.com/Attumm/settingo)](https://goreportcard.com/report/github.com/Attumm/settingo)\n[![CI](https://github.com/Attumm/settingo/actions/workflows/ci.yml/badge.svg)](https://github.com/Attumm/settingo/actions/workflows/ci.yml)\n[![codecov](https://codecov.io/gh/Attumm/settingo/branch/main/graph/badge.svg)](https://codecov.io/gh/Attumm/settingo)\n[![Go Reference](https://pkg.go.dev/badge/github.com/Attumm/settingo/settingo.svg)](https://pkg.go.dev/github.com/Attumm/settingo/settingo)\n\n## _Settings should be simple, and with settingo it is._\n\nSettingo parses command line and environment variables, all within one tool.\nSetting up settings is as simple as creating a struct with helpful messages for your project and --help on the CLI.\n```go\ntype Config struct {\n    APIKey    string `settingo:\"API key for authentication\"`\n}\n\nfunc main()  {\n    config := Config{\n        APIKey:    \"foo-bar\",\n    }\n    settingo.ParseTo(config)\n}\n```\n\nNow the struct will hold always hold value, either default, environment var, cli. based on the context making settings simple.\nLetting you focus on your project.\n```go\nconfig.APIKey\n```\n\n## Features\n- Simplicity: Set up settings within a single line of code.\n- Flexibility: Utilize command-line flags, environment variables, or defaults.\n- Typesafety: Seamlessly work with strings, integers, slices, booleans, and maps.\n- Convenience: Global access with a singleton pattern.\n- User-friendly: Automatic --help flag generation for your applications.\n- Versatility: Works flawlessly in Linux, Docker, Kubernetes, and other environments.\n\n## Example\nexample of how to use. More can be found in the [example_project](https://github.com/Attumm/settingo_example_project/blob/main/main.go)\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"github.com/Attumm/settingo/settingo\"\n)\n\n// Define your configuration with various types and help messages\ntype Config struct {\n\tAPIKey         string              `settingo:\"API key for authentication\"`\n\tPort           int                 `settingo:\"Port to run the server on\"`\n\tVerbose        bool                `settingo:\"Enable verbose output\"`\n\tHosts          []string            `settingo:\"List of allowed hosts (comma-separated)\"`\n\tItems          []string            `settingo:\"List of items (pipe-separated, sep=|)\" settingo:\"sep=|\"`\n\tHeaders        map[string][]string `settingo:\"HTTP headers to include (key:value1,value2;key2:value3 format)\"`\n}\n\nfunc main() {\n\t// Initialize config with default values\n\tconfig := \u0026Config{\n\t\tAPIKey:         \"foo-bar\",\n\t\tPort:           8080,\n\t\tVerbose:        true,\n\t\tHosts:          []string{\"localhost\", \"127.0.0.1\"},\n\t\tItems:          []string{\"alpha\", \"beta\", \"gamma\"},\n\t\tHeaders:        map[string][]string{\"Accept\": {\"application/json\"}},\n\t}\n\n\t// Parse command-line flags and environment variables into config\n\tsettingo.ParseTo(config)\n\n\t// Print out the configuration values\n\tfmt.Println(\"Configuration:\")\n\tfmt.Println(\"APIKey      =\", config.APIKey)\n\tfmt.Println(\"Port        =\", config.Port)\n\tfmt.Println(\"Verbose     =\", config.Verbose)\n\tfmt.Println(\"Headers     =\", config.Headers)\n\tfmt.Println(\"Hosts       =\", config.Hosts)\n\tfmt.Println(\"Items       =\", config.Items)\n}\n```\nWhen you build your application (e.g., go build -o myapp) and run ./myapp --help, settingo automatically generates help text based on struct tags and default values:\n```bash\nUsage of ./myapp:\n  -APIKEY string\n        API key for authentication (default \"foo-bar\")\n  -HEADERS string\n        HTTP headers to include (key:value1,value2;key2:value3 format) (default \"Accept:application/json\")\n  -HOSTS string\n        List of allowed hosts (comma-separated) (default \"localhost,127.0.0.1\")\n  -ITEMS string\n        List of items (pipe-separated, sep=|) (default \"alpha,beta,gamma\")\n  -PORT int\n        Port to run the server on (default 8080)\n  -VERBOSE string\n        Enable verbose output (default \"true\")\n```\n\n```go\npackage main\n\nimport (\n        \"fmt\"\n        \"github.com/Attumm/settingo/settingo\"\n)\n\nfunc main() {\n        settingo.Set(\"FOO\", \"default value\", \"handy help text\")\n        \n        settingo.Parse()\n        fmt.Println(\"foo =\",  settingo.Get(\"FOO\"))\n}\n```\nThe above go will produce binary that can be used as follows.\nGet handy help text set in the above example on the same line.\nThis can get very handy when the project grows and is used in different environments\n```sh\n$ ./example --help\nUsage of ./example:\n  -FOO string\n      handy help text (default \"default value\")\n```\n\nWhen no value is given, default value is used\n```sh\n$ ./example\nfoo = default value\n```\n\nRunning the binary with command line input\n```sh\n$ ./example -FOO bar\nfoo = bar\n```\nRunning the binary with environment variable\n```sh\n$ FOO=ok;./example\nfoo = ok\n```\n\n## Order of preference\nvariables are set with preference\nvariables on the command line will have highest preference.\nThis because while testing you might want to override environment\nThe priority order is as follows\n1. Command line input\n2. Environment variables \n3. Default values\n\n## Example: Custom Parsing for \"Messy\" Input with `SetParsed`\n\nSometimes, environment variables or command-line arguments might not be perfectly formatted.  You might receive an empty string, mixed-case input, or data that needs transformation.  `settingo`'s `SetParsed` is ideal for cleaning up and standardizing such \"messy\" input.\n\nThis example demonstrates handling a `RAW_USERNAME` environment variable, ensuring the `Username` setting is always a lowercase, non-empty string, defaulting to \"anonymous\" if the input is blank:\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n\t\"github.com/Attumm/settingo/settingo\"\n    \"strings\"\n)\n\n// Define your configuration with Parsed setting\ntype Config struct {\n    Username string `settingo:\"USERNAME for application access\"`\n}\n\nfunc main() {\n    config := \u0026Config{\n        Username: \"default\",\n    }\n\n    // Use SetParsed to handle potentially messy Username input\n    settingo.SetParsed(\"USERNAME\", \"default\", \"Username for application access\", func(input string) string {\n        if input == \"\" {\n            return \"anonymous\" // Default to \"anonymous\" if empty input\n        }\n        return strings.ToLower(input) // Convert username to lowercase\n    })\n\t\n    settingo.ParseTo(config)\n    fmt.Println(\"Configured Username:\", config.Username)\n}\n```\n\n```bash\n$./example\nConfigured Username: default\n$ ./example --USERNAME ''\nConfigured Username: anonymous\n$ ./example --USERNAME FOOBAR\nConfigured Username: foobar\n```\n\n## installation\n```bash\ngo get \"github.com/Attumm/settingo/settingo\"\n```\n\n## Example project\nHandy [example_project](https://github.com/Attumm/settingo_example_project) as starting point.\n\n## License\nMIT\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fattumm%2Fsettingo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fattumm%2Fsettingo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fattumm%2Fsettingo/lists"}