{"id":15662562,"url":"https://github.com/sivchari/tenv","last_synced_at":"2025-04-12T20:44:05.078Z","repository":{"id":37886884,"uuid":"403357351","full_name":"sivchari/tenv","owner":"sivchari","description":"tenv detects environment  variable not using t.Setenv","archived":false,"fork":false,"pushed_at":"2024-10-28T05:54:05.000Z","size":291,"stargazers_count":23,"open_issues_count":1,"forks_count":7,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-10-30T08:17:46.894Z","etag":null,"topics":["go","golang","govet","linter"],"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/sivchari.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":"2021-09-05T16:24:26.000Z","updated_at":"2024-10-28T05:53:52.000Z","dependencies_parsed_at":"2024-11-13T06:03:31.035Z","dependency_job_id":null,"html_url":"https://github.com/sivchari/tenv","commit_stats":{"total_commits":50,"total_committers":5,"mean_commits":10.0,"dds":"0.16000000000000003","last_synced_commit":"1ea85c7950ae91f9e615a37f8d373fc0276a7efd"},"previous_names":[],"tags_count":23,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sivchari%2Ftenv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sivchari%2Ftenv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sivchari%2Ftenv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sivchari%2Ftenv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sivchari","download_url":"https://codeload.github.com/sivchari/tenv/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248631687,"owners_count":21136556,"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":["go","golang","govet","linter"],"created_at":"2024-10-03T13:33:17.114Z","updated_at":"2025-04-12T20:44:05.058Z","avatar_url":"https://github.com/sivchari.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# tenv\n\n\u003cimg title=\"Gopher\" alt=\"tenv Gopher\" src=\"./tenv.png\" width=\"400\"\u003e\n\n\n[![test](https://github.com/sivchari/tenv/actions/workflows/test.yaml/badge.svg?branch=main)](https://github.com/sivchari/tenv/actions/workflows/test.yaml)\n\ntenv is analyzer that detects using os.Setenv instead of t.Setenv since Go1.17\n\n## Instruction\n\n```sh\ngo install github.com/sivchari/tenv/cmd/tenv@latest\n```\n\n## Usage\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"os\"\n\t\"testing\"\n)\n\nfunc TestMain(t *testing.T) {\n\tfmt.Println(os.Getenv(\"GO\"))\n\tos.Setenv(\"GO\", \"HACKING GOPHER\")\n}\n\nfunc TestMain2(t *testing.T) {\n\tfmt.Println(os.Getenv(\"GO\"))\n}\n\nfunc helper() {\n\tos.Setenv(\"GO\", \"HACKING GOPHER\")\n}\n```\n\n```console\ngo vet -vettool=$(which tenv) ./...\n\n# a\n./main_test.go:11:2: os.Setenv() can be replaced by `t.Setenv()` in TestMain\n```\n\n### option\n\nThe option `all` will run against whole test files (`_test.go`) regardless of method/function signatures.  \n\nBy default, only methods that take `*testing.T`, `*testing.B`, and `testing.TB` as arguments are checked.\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"os\"\n\t\"testing\"\n)\n\nfunc TestMain(t *testing.T) {\n\tfmt.Println(os.Getenv(\"GO\"))\n\tos.Setenv(\"GO\", \"HACKING GOPHER\")\n}\n\nfunc TestMain2(t *testing.T) {\n\tfmt.Println(os.Getenv(\"GO\"))\n}\n\nfunc helper() {\n\tos.Setenv(\"GO\", \"HACKING GOPHER\")\n}\n```\n\n```console\ngo vet -vettool=$(which tenv) -tenv.all ./...\n\n# a\n./main_test.go:11:2: os.Setenv() can be replaced by `t.Setenv()` in TestMain\n./main_test.go:19:2: os.Setenv() can be replaced by `testing.Setenv()` in helper\n```\n\n## CI\n\n### CircleCI\n\n```yaml\n- run:\n    name: install tenv\n    command: go install github.com/sivchari/tenv@latest\n\n- run:\n    name: run tenv\n    command: go vet -vettool=`which tenv` ./...\n```\n\n### GitHub Actions\n\n```yaml\n- name: install tenv\n  run: go install github.com/sivchari/tenv@latest\n\n- name: run tenv\n  run: go vet -vettool=`which tenv` ./...\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsivchari%2Ftenv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsivchari%2Ftenv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsivchari%2Ftenv/lists"}