{"id":13694091,"url":"https://github.com/jgautheron/goconst","last_synced_at":"2025-05-14T07:09:07.614Z","repository":{"id":49865618,"uuid":"48519006","full_name":"jgautheron/goconst","owner":"jgautheron","description":"Find in Go repeated strings that could be replaced by a constant","archived":false,"fork":false,"pushed_at":"2025-04-17T20:18:14.000Z","size":76,"stargazers_count":302,"open_issues_count":0,"forks_count":20,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-04-18T10:43:17.524Z","etag":null,"topics":["go","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/jgautheron.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,"zenodo":null}},"created_at":"2015-12-24T01:42:15.000Z","updated_at":"2025-04-17T20:18:18.000Z","dependencies_parsed_at":"2023-11-10T14:49:31.221Z","dependency_job_id":"b64c30b7-9b56-46d9-a097-ebaa2331451f","html_url":"https://github.com/jgautheron/goconst","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jgautheron%2Fgoconst","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jgautheron%2Fgoconst/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jgautheron%2Fgoconst/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jgautheron%2Fgoconst/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jgautheron","download_url":"https://codeload.github.com/jgautheron/goconst/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254092777,"owners_count":22013290,"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","linter"],"created_at":"2024-08-02T17:01:24.056Z","updated_at":"2025-05-14T07:09:02.593Z","avatar_url":"https://github.com/jgautheron.png","language":"Go","funding_links":[],"categories":["开源类库","Open source library","Linters","Go","Programming Languages"],"sub_categories":["代码分析","Code Analysis","Style and Patterns Checking"],"readme":"# goconst\n\nFind repeated strings that could be replaced by a constant.\n\n### Motivation\n\nThere are obvious benefits to using constants instead of repeating strings, mostly to ease maintenance. Cannot argue against changing a single constant versus many strings.\n\nWhile this could be considered a beginner mistake, across time, multiple packages and large codebases, some repetition could have slipped in.\n\n### Get Started\n\n    $ go install github.com/jgautheron/goconst/cmd/goconst@latest\n    $ goconst ./...\n\n### Usage\n\n```\nUsage:\n\n  goconst ARGS \u003cdirectory\u003e\n\nFlags:\n\n  -ignore            exclude files matching the given regular expression\n  -ignore-strings    exclude strings matching the given regular expression\n  -ignore-tests      exclude tests from the search (default: true)\n  -min-occurrences   report from how many occurrences (default: 2)\n  -min-length        only report strings with the minimum given length (default: 3)\n  -match-constant    look for existing constants matching the values\n  -find-duplicates   look for constants with identical values\n  -numbers           search also for duplicated numbers\n  -min          \t   minimum value, only works with -numbers\n  -max          \t   maximum value, only works with -numbers\n  -output            output formatting (text or json)\n  -set-exit-status   Set exit status to 2 if any issues are found\n\nExamples:\n\n  goconst ./...\n  goconst -ignore \"yacc|\\.pb\\.\" $GOPATH/src/github.com/cockroachdb/cockroach/...\n  goconst -min-occurrences 3 -output json $GOPATH/src/github.com/cockroachdb/cockroach\n  goconst -numbers -min 60 -max 512 .\n  goconst -min-occurrences 5 $(go list -m -f '{{.Dir}}')\n```\n\n### Development\n\n#### Running Tests\n\nThe project includes a comprehensive test suite. To run the tests:\n\n```bash\n# Run all tests\ngo test ./...\n\n# Run tests with verbose output\ngo test -v ./...\n\n# Run tests with race detector\ngo test -race ./...\n\n# Run benchmarks\ngo test -bench=. ./...\n\n# Check test coverage\ngo test -cover ./...\n```\n\n#### Contributing\n\nContributions are welcome! Before submitting a PR:\n\n1. Make sure all tests pass\n2. Add tests for new functionality\n3. Ensure your code passes linting checks\n4. Update documentation as needed\n\n### Other static analysis tools\n\n- [gogetimports](https://github.com/jgautheron/gogetimports): Get a JSON-formatted list of imports.\n- [usedexports](https://github.com/jgautheron/usedexports): Find exported variables that could be unexported.\n\n### License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjgautheron%2Fgoconst","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjgautheron%2Fgoconst","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjgautheron%2Fgoconst/lists"}