{"id":22412895,"url":"https://github.com/deeper-x/goenv","last_synced_at":"2025-03-27T03:23:57.676Z","repository":{"id":195375029,"uuid":"692754248","full_name":"deeper-x/goenv","owner":"deeper-x","description":"manage dotenv .env parameters from golang ","archived":false,"fork":false,"pushed_at":"2024-07-02T10:42:19.000Z","size":25,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-01T08:47:29.244Z","etag":null,"topics":["dotenv","dotenv-parser","golang"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/deeper-x.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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-09-17T13:39:32.000Z","updated_at":"2024-07-02T10:42:22.000Z","dependencies_parsed_at":"2024-05-21T18:02:34.689Z","dependency_job_id":"002faa25-1795-4ffc-bf74-5ffb077e8668","html_url":"https://github.com/deeper-x/goenv","commit_stats":null,"previous_names":["deeper-x/golang-dot-env","deeper-x/goenv"],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deeper-x%2Fgoenv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deeper-x%2Fgoenv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deeper-x%2Fgoenv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deeper-x%2Fgoenv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/deeper-x","download_url":"https://codeload.github.com/deeper-x/goenv/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245774456,"owners_count":20669961,"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":["dotenv","dotenv-parser","golang"],"created_at":"2024-12-05T14:11:15.402Z","updated_at":"2025-03-27T03:23:57.654Z","avatar_url":"https://github.com/deeper-x.png","language":"Go","readme":"### Golang Dot Env\n\nHandle .env parameters in golang.\n\nUsage:\n\nStep 1 - Install:\n```sh\ngo get -v github.com/deeper-x/goenv@latest\n```\n\nStep 2 - Create an .env:\n```txt\nUSER=demo_user\nPASSWORD=qwerty\n```\n\nStep 3 - Deploy:\n```golang\npackage main\n\nimport (\n\t\"fmt\"\n\t\"github.com/deeper-x/goenv\"\n)\n\n\nfunc main() {\n\tcfo, err := goenv.New(\".env\")\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tusername, err := cfo.Get(\"USERNAME\")\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tpassword, err := cfo.Get(\"PASSWORD\")\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Printf(\"user: %s; password: %s\", username, password)\n}\n\n// Output:\n// user: demo_user; password: qwerty\n```\n\nTest:\n```golang\ngo test -v ./...\n```\n\n### Details\n\nBuild file object:\n```golang\nefo, err := goenv.New() // \u003c-- access default .env file in current dir, or New(\"./assets/.env\") for custom file path\nif err != nil {\n\tpanic(err)\n}\n```\nInspect file content:\n```golang\nfc, err := FileDump()\nif err != nil {\n\tpanic(err)\n}\n\nfmt.Println(fc)\n```\n\nAccess .env parameters:\n```golang\nv, err = cfo.Get(\"USERNAME\")\nif err == nil {\n    panic(\"...handle error...\")\n}\n\nfmt.Println(v) // \u003c-- access environment value\n```\n\n\n\nPLEASE NOTE: Accessing non existing variables raises an error!\n```golang\nefo, err := goenv.New()\nif err != nil {\n    panic(err)\n}\n\nv, err = efo.Get(\"NON_EXISTING\")\nif err != nil {\n    panic(\"handle error on non-existing key fetched\")\n}\n```\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeeper-x%2Fgoenv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdeeper-x%2Fgoenv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeeper-x%2Fgoenv/lists"}