{"repo":"jgautheron/goconst","free":true,"listed":false,"github":"https://github.com/jgautheron/goconst","clone":"git clone https://github.com/jgautheron/goconst.git","description":"Find in Go repeated strings that could be replaced by a constant","language":"Go","stars":320,"topics":["go","linter"],"license":"MIT","category":"dev-tools","readme_excerpt":"goconst Find repeated strings that could be replaced by a constant. Motivation There are obvious benefits to using constants instead of repeating strings, mostly to ease maintenance. Cannot argue against changing a single constant versus many strings. While this could be considered a beginner mistake, across time, multiple packages and large codebases, some repetition could have slipped in. How it works goconst detects string (and optionally number) literals that appear multiple times and could be replaced by a constant. A few things to keep in mind: - Exact literal matching — goconst compares complete, unquoted literal values. Repeated substrings inside larger strings are not detected (e.g., a shared prefix across two different string literals will not be reported). - const declarations are skipped by default — constant values are only analyzed when -match-constant (match strings against existing constants) or -find-duplicates (find constants sharing the same value) is enabled. - String length is measured in runes , not bytes, so multi-byte Unicode characters are counted correctly against -min-length . Get Started $ go install github.com/jgautheron/goconst/cmd/goconst@latest $ goconst ./... Usage Development Running Tests The project includes a comprehensive test suite. To run the tests: Contributing Contributions are welcome! Before submitting a PR: 1. Make sure all tests pass 2. Add tests for new functionality 3. Ensure your code passes linting checks 4. Update documentati","default_branch":null,"files":null,"tree":[],"storefront":"/r/jgautheron","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/jgautheron/goconst/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}