Need help with goconst?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

208 Stars 13 Forks MIT License 28 Commits 0 Opened issues


Find in Go repeated strings that could be replaced by a constant

Services available


Need anything else?

Contributors list


Find repeated strings that could be replaced by a constant.


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.

Get Started

$ go get
$ goconst ./...



goconst ARGS


-ignore exclude files matching the given regular expression -ignore-tests exclude tests from the search (default: true) -min-occurrences report from how many occurrences (default: 2) -min-length only report strings with the minimum given length (default: 3) -match-constant look for existing constants matching the values -numbers search also for duplicated numbers -min minimum value, only works with -numbers -max maximum value, only works with -numbers -output output formatting (text or json) -set-exit-status Set exit status to 2 if any issues are found


goconst ./... goconst -ignore "yacc|.pb." $GOPATH/src/ goconst -min-occurrences 3 -output json $GOPATH/src/ goconst -numbers -min 60 -max 512 .

Other static analysis tools

  • gogetimports: Get a JSON-formatted list of imports.
  • usedexports: Find exported variables that could be unexported.



We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.