{"id":39689748,"url":"https://github.com/nate-anderson/fig","last_synced_at":"2026-01-18T10:04:24.624Z","repository":{"id":57543498,"uuid":"295102887","full_name":"nate-anderson/fig","owner":"nate-anderson","description":"Juicy config from environment in Go","archived":false,"fork":false,"pushed_at":"2024-03-12T00:57:23.000Z","size":273,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"v2","last_synced_at":"2025-11-29T23:51:46.178Z","etag":null,"topics":["config","dotenv","env","environment","go","godotenv","golang"],"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/nate-anderson.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}},"created_at":"2020-09-13T07:44:15.000Z","updated_at":"2023-04-22T07:10:23.000Z","dependencies_parsed_at":"2024-03-12T02:06:10.699Z","dependency_job_id":null,"html_url":"https://github.com/nate-anderson/fig","commit_stats":{"total_commits":24,"total_committers":2,"mean_commits":12.0,"dds":0.125,"last_synced_commit":"c6e548b17399dadfb380d840e6e2cbab4ed80f2f"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/nate-anderson/fig","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nate-anderson%2Ffig","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nate-anderson%2Ffig/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nate-anderson%2Ffig/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nate-anderson%2Ffig/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nate-anderson","download_url":"https://codeload.github.com/nate-anderson/fig/tar.gz/refs/heads/v2","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nate-anderson%2Ffig/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28534215,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-18T00:39:45.795Z","status":"online","status_checked_at":"2026-01-18T02:00:07.578Z","response_time":98,"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":["config","dotenv","env","environment","go","godotenv","golang"],"created_at":"2026-01-18T10:04:24.571Z","updated_at":"2026-01-18T10:04:24.618Z","avatar_url":"https://github.com/nate-anderson.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg src=\"https://github.com/nate-anderson/fig/blob/master/figs.jpg\" width=\"250\" alt=\"Figs\"\u003e\n\n# fig\n\n[![Build and test Go package](https://github.com/nate-anderson/fig/actions/workflows/ci.yml/badge.svg)](https://github.com/nate-anderson/fig/actions/workflows/ci.yml)\n\n[![Go Report Card](https://goreportcard.com/badge/github.com/nate-anderson/fig/v2)](https://goreportcard.com/report/github.com/nate-anderson/fig/v2)\n\n[![Go Reference](https://pkg.go.dev/badge/github.com/nate-anderson/fig/v2.svg)](https://pkg.go.dev/github.com/nate-anderson/fig/v2)\n\nJuicy extensible config in Go\n\nFig wraps John Barton's [godotenv](https://github.com/joho/godotenv) with convenience methods for type validation and struct unmarshaling. I wrote this as a subpackage\nfor another project and extracted it to this repo for easy reuse.\n\n`go get github.com/nate-anderson/fig/v2`\n\n## Initializing\n\nCalling `fig.New()` with no parameters initializes a Config object that reads from the\nenvironment. Passing drivers to `New()` tells `fig` where to check for configuration variables\nand your preferred precedence. A driver is any type that allows `fig` to read string values\nby key.\n\nA driver for reading from `.env` files is included.\n\n```go\nenvDriver, err := NewEnvironmentDriver(\".env\", \"local.env\")\nconf := fig.New(envDriver)\n```\n\n`fig.Config` has methods for retrieving `string`s, `int`s, `int64`s, `float64`s and `bool`s.\n\n- GetString\n- GetInt\n- GetInt64\n- GetBool\n- GetFloat64\n\nThese methods return an `error` if the variable is not configured or if the string in the environment cannot be parsed into the appropriate type. The following methods will panic on missing or malformed variables:\n\n- MustGetString\n- MustGetInt\n- MustGetInt64\n- MustGetBool\n- MustGetFloat64\n\nThese are useful for required configuration variables for which repeated error checks are a PITA.\n\nFor retrieving variables with hard-coded defaults, use the `...Or` set of methods:\n\n- GetStringOr\n- GetIntOr\n- GetInt64Or\n- GetBoolOr\n- GetFloatOr\n\n## Struct Unmarshaling\n\nUse the `fig` and `required` struct tags to decorate your configuration structs and quickly\nread from your configuration providers. This function makes use of reflection so it is not necessarily optimal for repeated runtime unmarshals.\n\n```go\ntype Config struct {\n    DBHost string  `fig:\"DB_HOST\" required:\"true\"`\n    DBPort *int    `fig:\"DB_PORT\"`\n    DBUser string  `fig:\"DB_USER\"`\n    DBPass *string `fig:\"DB_PASS\"`\n}\n\nvar appConfig Config\n\nfunc init() {\n    envDriver, _ := NewEnvironmentDriver(\".env\", \"local.env\")\n    conf := fig.New(envDriver)\n    err := conf.Unmarshal(\u0026appConfig)\n}\n```\n\nIf you need more advanced struct unmarshaling for configuration, I recommend [viper](https://github.com/spf13/viper).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnate-anderson%2Ffig","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnate-anderson%2Ffig","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnate-anderson%2Ffig/lists"}