{"id":15754765,"url":"https://github.com/miniscruff/envexample","last_synced_at":"2025-03-13T15:33:04.952Z","repository":{"id":164912754,"uuid":"634659195","full_name":"miniscruff/envexample","owner":"miniscruff","description":"Generate a .env.example from an env struct","archived":false,"fork":false,"pushed_at":"2024-07-09T00:27:23.000Z","size":99,"stargazers_count":3,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-10-05T08:04:42.271Z","etag":null,"topics":[],"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/miniscruff.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2023-04-30T20:44:58.000Z","updated_at":"2024-07-09T00:27:26.000Z","dependencies_parsed_at":null,"dependency_job_id":"f8b5dc31-c952-4e45-b795-3d04a9256dec","html_url":"https://github.com/miniscruff/envexample","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miniscruff%2Fenvexample","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miniscruff%2Fenvexample/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miniscruff%2Fenvexample/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miniscruff%2Fenvexample/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/miniscruff","download_url":"https://codeload.github.com/miniscruff/envexample/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221384246,"owners_count":16809943,"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":[],"created_at":"2024-10-04T08:04:45.935Z","updated_at":"2024-10-25T04:22:02.910Z","avatar_url":"https://github.com/miniscruff.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# EnvExample\n\n[![codecov](https://codecov.io/gh/miniscruff/envexample/branch/main/graph/badge.svg?token=7HT2E32FMB)](https://codecov.io/gh/miniscruff/envexample)\n[![Go Report Card](https://goreportcard.com/badge/github.com/miniscruff/envexample)](https://goreportcard.com/report/github.com/miniscruff/envexample)\n[![Release](https://img.shields.io/github/v/release/miniscruff/envexample?sort=semver)](https://github.com/miniscruff/envexample/releases)\n[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/miniscruff/envexample/test.yml?branch=main)](https://github.com/miniscruff/envexample/actions?query=workflow%3Atest)\n[![PkgGoDev](https://pkg.go.dev/badge/github.com/miniscruff/envexample)](https://pkg.go.dev/github.com/miniscruff/envexample)\n\nGenerate a `.env.example` from an [env labeled](https://github.com/caarlos0/env) struct\n\n## Installation\nThe easiest way to install `envexample` is using `go install` from latest or by version.\n\n```sh\ngo install github.com/miniscruff/envexample@latest\ngo install github.com/miniscruff/envexample@v0.1.0\n```\n\n[All Installation Options](#all-installation-options) has the full list of options.\n\n[CLI Arguments](./DOCS.md) has all the arguments.\n\n## Usage\nGiven a configuration struct and using [env](https://github.com/caarlos0/env)\nto parse environment variables like:\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/caarlos0/env/v9\"\n\t\"github.com/joho/godotenv\"\n)\n\n// Config handles our applications configuration\ntype Config struct {\n\t// Home is our users home directory\n\tHome string `env:\"HOME\"`\n\t// Port is our http listeners port address\n\tPort int `env:\"PORT\" envDefault:\"3000\"`\n\t// IsProduction is whether or not we are running in production\n\tIsProduction bool `env:\"PRODUCTION\"`\n}\n\nfunc main() {\n\t// attempt to load .env file if found\n\t_ = godotenv.Load()\n\n\tcfg := Config{}\n\tif err := env.Parse(\u0026cfg); err != nil {\n\t\tfmt.Printf(\"%+v\\n\", err)\n    }\n\n\tfmt.Printf(\"%+v\\n\", cfg)\n}\n```\n\nYou can run `envexample` like:\n```sh\nenvexample -struct Config\n```\n\nTo generate an `.env.example` file similar to:\n```sh\n# Generated by envexample dev.\n\n# Config handles our applications configuration\n#\n# Home is our users home directory\n#HOME=\"\"\n# IsProduction is whether or not we are running in production\n#PRODUCTION=\"\"\n# Port is our http listeners port address\n#PORT=3000\n```\n\nThis file should be commited to your source control, and a copy should be created\nlocally that is then loaded by your application.\n\nSomething similar to `cp .env.example .env` would work.\n\n## All Installation Options\n\n### deb/rpm\nDownload a `.deb` or `.rpm` file from the [releases page](https://github.com/miniscruff/envexample/releases)\nand install with `dpkg -i` and `rpm -i` respectively.\n\n### Windows Scoop\nOn windows you can use [scoop](https://scoop.sh/) by first adding the repo and then installing.\n```sh\nscoop bucket add envexample https://github.com/miniscruff/envexample\nscoop install envexample\n```\n\n### macOS with Homebrew\n\nOn macOS, you can use [Homebrew](https://brew.sh/) to install by first tapping\nthe repository.\n\n```sh\nbrew tap miniscruff/envexample https://github.com/miniscruff/envexample\nbrew install envexample\n```\n\n### Manual\n* Download from [here](https://github.com/miniscruff/envexample/releases).\n* Add executable somewhere in your path depending on your platform.\n\n### From source\nGo install can be used to download envexample from the main branch or by tag.\n\n```\ngo install github.com/miniscruff/envexample@latest\ngo install github.com/miniscruff/envexample@v0.1.0\n```\n\n## Tasks\nBelow is a list of common development tasks, these can easily be run using [xc](https://xcfile.dev/).\nFor example `xc test` will run the test suite.\n\n### test\nRun unit test suite with code coverage enabled.\n```\ngo test ./... -coverprofile=c.out\n```\n\n### coverage\nRun unit tests and preview the html coverage results.\nrequires: test\n```\ngo tool cover -html=c.out\n```\n\n### lint\n```\ngoimports -w -local github.com/miniscruff/envexample .\ngolangci-lint run ./...\n```\n\n### release\nRun generation and prepare a release PR\nrequires: test,lint\n```\ngo run main.go -h \u003e DOCS.md\nchangie batch auto\nchangie merge\ngit checkout --branch release-$(changie latest)\ngh pr create\n```\n\n## License\nDistributed under the [MIT License](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fminiscruff%2Fenvexample","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fminiscruff%2Fenvexample","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fminiscruff%2Fenvexample/lists"}