{"id":16179728,"url":"https://github.com/bep/punused","last_synced_at":"2025-03-16T10:31:35.390Z","repository":{"id":37421952,"uuid":"448250957","full_name":"bep/punused","owner":"bep","description":"Finds unused _exported_ Go symbols in a project. Backed by gopls.","archived":false,"fork":false,"pushed_at":"2024-08-09T10:01:59.000Z","size":25,"stargazers_count":39,"open_issues_count":2,"forks_count":6,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-02-27T07:40:10.222Z","etag":null,"topics":["golang","golang-application"],"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/bep.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":["bep"]}},"created_at":"2022-01-15T10:53:09.000Z","updated_at":"2024-11-30T17:20:32.000Z","dependencies_parsed_at":"2024-06-19T05:30:02.252Z","dependency_job_id":"4b15badd-3e4f-4153-9bb9-6212a1465e05","html_url":"https://github.com/bep/punused","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bep%2Fpunused","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bep%2Fpunused/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bep%2Fpunused/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bep%2Fpunused/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bep","download_url":"https://codeload.github.com/bep/punused/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243810851,"owners_count":20351596,"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":["golang","golang-application"],"created_at":"2024-10-10T05:43:54.007Z","updated_at":"2025-03-16T10:31:35.006Z","avatar_url":"https://github.com/bep.png","language":"Go","funding_links":["https://github.com/sponsors/bep"],"categories":[],"sub_categories":[],"readme":"[![Go](https://github.com/bep/punused/actions/workflows/go.yml/badge.svg)](https://github.com/bep/punused/actions/workflows/go.yml)\n\nThis is a small utility that finds _unused exported Go symbols_ (functions, methods ...) in Go. For all other similar use cases, use https://github.com/dominikh/go-tools\n\nI have used this in Hugo (a monorepo with many packages), and it works, but there are some caveats:\n\n* It does not detect references from outside of your project.\n* It does not detect references via `reflect`.\n* Some possible surprises when it comes to interfaces.\n\nSo, you should inspect and test the proposed deletes. See this [test repo](https://github.com/bep/unused-test) for more information.\n\n## Install\n\n```bash\ngo install github.com/bep/punused@latest\n```\n\nYou also need `gopls`:\n\n```bash\ngo install golang.org/x/tools/gopls@latest\n```\n\n## Use\n\n`punused` takes only one (optional) argument: A [Glob](https://github.com/gobwas/glob) filename pattern (Unix style slashes, double asterisk is supported) of Go files to check.\n\n`punused` needs to be run from the root of a Go Module. To test a specific package you can target it with a Glob, e.g. `punused \"utils/*.go\"`.\n\nRunning `punused` in this repository currently gives:\n\n```\npunused                                                                \ninternal/lib/gopls.go:125:2 field Detail is unused (EU1002)\ninternal/lib/gopls.go:135:2 field Tags is unused (EU1002)\ninternal/lib/gopls.go:141:2 field Deprecated is unused (EU1002)\ninternal/lib/gopls.go:147:2 field Range is unused (EU1002)\ninternal/lib/testpackages/firstpackage/code1.go:7:2 variable UnusedVar is unused (EU1002)\ninternal/lib/testpackages/firstpackage/code1.go:12:2 constant UnusedConst is unused (EU1002)\ninternal/lib/testpackages/firstpackage/code1.go:19:6 function UnusedFunction is unused (EU1002)\ninternal/lib/testpackages/firstpackage/code1.go:25:2 field UnusedField is unused (EU1002)\ninternal/lib/testpackages/firstpackage/code1.go:32:15 method (MyType).UnusedMethod is unused (EU1002)\ninternal/lib/testpackages/firstpackage/code1.go:36:6 interface UnusedInterfaceWithUsedAndUnusedMethod is unused (EU1002)\ninternal/lib/testpackages/firstpackage/code1.go:38:2 method UnusedInterfaceMethodReturningInt is unused (EU1002)\ninternal/lib/testpackages/firstpackage/code1.go:37:2 method UsedInterfaceMethodReturningInt is unused (EU1002)\ninternal/lib/testpackages/firstpackage/code1.go:41:6 interface UnusedInterface is unused (EU1002)\ninternal/lib/testpackages/firstpackage/code1.go:42:2 method UnusedInterfaceReturningInt is unused (EU1002)\ninternal/lib/testpackages/firstpackage/code1.go:45:6 interface UsedInterface is unused (EU1002)\ninternal/lib/testpackages/firstpackage/testlib1.go:4:2 constant OnlyUsedInTestConst is used in test only (EU1001)\n```\n\nNote that we currently skip checking test code, but you do warned about unused symbols only used in tests (see example above).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbep%2Fpunused","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbep%2Fpunused","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbep%2Fpunused/lists"}