{"id":20275154,"url":"https://github.com/samuelbankstech/go-environment","last_synced_at":"2025-03-04T01:28:23.265Z","repository":{"id":57704650,"uuid":"498332890","full_name":"SamuelBanksTech/Go-Environment","owner":"SamuelBanksTech","description":null,"archived":false,"fork":false,"pushed_at":"2022-10-11T15:15:13.000Z","size":21,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-14T06:27:17.897Z","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":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SamuelBanksTech.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":"2022-05-31T12:47:06.000Z","updated_at":"2023-10-25T21:48:19.000Z","dependencies_parsed_at":"2022-09-26T21:20:13.583Z","dependency_job_id":null,"html_url":"https://github.com/SamuelBanksTech/Go-Environment","commit_stats":null,"previous_names":["samuelbankstech/env"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SamuelBanksTech%2FGo-Environment","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SamuelBanksTech%2FGo-Environment/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SamuelBanksTech%2FGo-Environment/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SamuelBanksTech%2FGo-Environment/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SamuelBanksTech","download_url":"https://codeload.github.com/SamuelBanksTech/Go-Environment/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241766605,"owners_count":20016788,"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-11-14T13:08:14.931Z","updated_at":"2025-03-04T01:28:23.243Z","avatar_url":"https://github.com/SamuelBanksTech.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Environment variable loader\n\nWhy use this over `os.Getenv(\"FOO\")`? Read below to find out!\n\nThis package will load an environment variable file (usually a .env file placed in the root) and have these variables globally available using `env.Get(\"FOO\")`.\nYou can optionally allow 'real' environment variables to override the variables in the .env file allowing for some nice defaults to be set in the case of a missing environment variable.\n\nWhat's more, unlike other env loaders, the variables contained in your .env file do not actually get set in the real environment and are only available to the running Go application making them more secure to malicious code that may be running on the same server. \n\nUsing `env.Get(\"XXX\")` can completly replace `os.Getenv(\"XXX\")` if there is no variable in the file then next check will be the 'real' environment.\n\n#### Usage\n\n`go get github.com/SamuelBanksTech/Go-Environment`\n\n\n#### Basic Example\n```go\npackage main\n\nimport (\n\t\"fmt\"\n    \"log\"\n\t\"github.com/SamuelBanksTech/Go-Environment\"\n)\n\nfunc main() {\n\n\t//Init env vars\n\tenvinit := env.Environment{\n\t\tEnvPath:             \".env\",\n\t\tEnableOsEnvOverride: true,\n\t\tHideOutput:          false,\n\t}\n\n\terr := envinit.LoadEnv()\n\tif err != nil {\n\t\tlog.Fatalln(err)\n\t}\n\t\n\tfmt.Println(env.Get(\"FOO\"))\n\t\n}\n```\n#### Example .env\n\n```dotenv\nFOO=bar\nBAR=donk\n#IGNOREDVAR=foobar\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamuelbankstech%2Fgo-environment","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsamuelbankstech%2Fgo-environment","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamuelbankstech%2Fgo-environment/lists"}