From b9dd045499aefe0d64cfa2312f167166f613a80d Mon Sep 17 00:00:00 2001 From: Mark van der Velden Date: Wed, 24 Jun 2026 12:18:09 +0200 Subject: [PATCH 1/3] Bumping versions --- .circleci/config.yml | 6 +++--- Dockerfile | 2 +- finder/processor_test.go | 1 + go.mod | 14 +++++++------- go.sum | 31 ++++++++++++++++--------------- 5 files changed, 28 insertions(+), 26 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 562a658..6227c81 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -4,7 +4,7 @@ version: 2 jobs: build-and-test: docker: - - image: cimg/go:1.20 + - image: cimg/go:1.25 environment: BINARY_NAME: "TySug-linux-amd64" @@ -34,7 +34,7 @@ jobs: - run: name: Lint command: | - curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.47.0 + curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v2.12.2 golangci-lint run - run: @@ -85,4 +85,4 @@ workflows: tags: only: /v[0-9]+(\.[0-9]+)*/ branches: - ignore: /.*/ \ No newline at end of file + ignore: /.*/ diff --git a/Dockerfile b/Dockerfile index 832d0b9..cdb552d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.18 as build +FROM golang:1.25 as build ARG VERSION="dev" ENV GOFLAGS="-buildvcs=false" diff --git a/finder/processor_test.go b/finder/processor_test.go index 321ce3c..7c47891 100644 --- a/finder/processor_test.go +++ b/finder/processor_test.go @@ -122,6 +122,7 @@ func FuzzMarkingTypoReplacer(f *testing.F) { "Nothing to see ha^Here, moving along!", "World Wide Mess^WWeb", "When the Hare eats the ^, or when the ^Eats^WThe^WHare", + "⌘", } for _, tt := range tests { diff --git a/go.mod b/go.mod index 653f94f..a39c370 100644 --- a/go.mod +++ b/go.mod @@ -1,19 +1,19 @@ module github.com/Dynom/TySug require ( - github.com/BurntSushi/toml v1.0.0 + github.com/BurntSushi/toml v1.6.0 github.com/NYTimes/gziphandler v1.1.1 github.com/alextanhongpin/stringdist v0.0.1 - github.com/rs/cors v1.8.2 - github.com/sirupsen/logrus v1.8.1 - github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 + github.com/rs/cors v1.11.1 + github.com/sirupsen/logrus v1.9.4 + github.com/xrash/smetrics v0.0.0-20250705151800-55b8f293f342 github.com/zikes/sift4 v0.0.0-20151103205100-8e89a8aebc1f gopkg.in/tomb.v2 v2.0.0-20161208151619-d5d1b5820637 ) require ( - golang.org/x/net v0.0.0-20220401154927-543a649e0bdd // indirect - golang.org/x/sys v0.0.0-20220330033206-e17cdc41300f // indirect + golang.org/x/net v0.56.0 // indirect + golang.org/x/sys v0.46.0 // indirect ) -go 1.20 +go 1.25.0 diff --git a/go.sum b/go.sum index 21f63cc..1eaaadf 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -github.com/BurntSushi/toml v1.0.0 h1:dtDWrepsVPfW9H/4y7dDgFc2MBUSeJhlaDtK13CxFlU= -github.com/BurntSushi/toml v1.0.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= +github.com/BurntSushi/toml v1.6.0 h1:dRaEfpa2VI55EwlIW72hMRHdWouJeRF7TPYhI+AUQjk= +github.com/BurntSushi/toml v1.6.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho= github.com/NYTimes/gziphandler v1.1.1 h1:ZUDjpQae29j0ryrS0u/B8HZfJBtBQHjqw2rQ2cqUQ3I= github.com/NYTimes/gziphandler v1.1.1/go.mod h1:n/CVRwUEOgIxrgPvAQhUUr9oeUtvrhMomdKFjzJNB0c= github.com/alextanhongpin/stringdist v0.0.1 h1:5Bygn3NKAoiUld8oYtoS8YplILTjOWxKe7FPAfXXs+U= @@ -9,22 +9,23 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/rs/cors v1.8.2 h1:KCooALfAYGs415Cwu5ABvv9n9509fSiG5SQJn/AQo4U= -github.com/rs/cors v1.8.2/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU= -github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE= -github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= +github.com/rs/cors v1.11.1 h1:eU3gRzXLRK57F5rKMGMZURNdIG4EoAmX8k94r9wXWHA= +github.com/rs/cors v1.11.1/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU= +github.com/sirupsen/logrus v1.9.4 h1:TsZE7l11zFCLZnZ+teH4Umoq5BhEIfIzfRDZ1Uzql2w= +github.com/sirupsen/logrus v1.9.4/go.mod h1:ftWc9WdOfJ0a92nsE2jF5u5ZwH8Bv2zdeOC42RjbV2g= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU= -github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8= +github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= +github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/xrash/smetrics v0.0.0-20250705151800-55b8f293f342 h1:FnBeRrxr7OU4VvAzt5X7s6266i6cSVkkFPS0TuXWbIg= +github.com/xrash/smetrics v0.0.0-20250705151800-55b8f293f342/go.mod h1:Ohn+xnUBiLI6FVj/9LpzZWtj1/D6lUovWYBkxHVV3aM= github.com/zikes/sift4 v0.0.0-20151103205100-8e89a8aebc1f h1:uwsos4EwJT8IjkwPbPl78dIoouY41YQt4ocQAAKo5+o= github.com/zikes/sift4 v0.0.0-20151103205100-8e89a8aebc1f/go.mod h1:RkT6UOQ/xx22IhYMzJoJsW3eMFc96fptPf6k/0dgncE= -golang.org/x/net v0.0.0-20220401154927-543a649e0bdd h1:zYlwaUHTmxuf6H7hwO2dgwqozQmH7zf4x+/qql4oVWc= -golang.org/x/net v0.0.0-20220401154927-543a649e0bdd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20220330033206-e17cdc41300f h1:rlezHXNlxYWvBCzNses9Dlc7nGFaNMJeqLolcmQSSZY= -golang.org/x/sys v0.0.0-20220330033206-e17cdc41300f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/net v0.56.0 h1:Rw8j/hFzGvJUZwNBXnAtf5sVDVt+65SK2C7IxCxZt5o= +golang.org/x/net v0.56.0/go.mod h1:D3Ku6r+V6JROoZK144D2XfMHFcMq/0zSfLelVTCFKec= +golang.org/x/sys v0.46.0 h1:noSf2Fq6F8DBgS+LysIkx7rIExoNHJsxOAtPp4rthXw= +golang.org/x/sys v0.46.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw= gopkg.in/tomb.v2 v2.0.0-20161208151619-d5d1b5820637 h1:yiW+nvdHb9LVqSHQBXfZCieqV4fzYhNBql77zY0ykqs= gopkg.in/tomb.v2 v2.0.0-20161208151619-d5d1b5820637/go.mod h1:BHsqpu/nsuzkT5BpiH1EMZPLyqSMM8JbIavyFACoFNk= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= From bcbb0cb6c9da5dbb608a72d6d009287334fd4d3a Mon Sep 17 00:00:00 2001 From: Mark van der Velden Date: Wed, 24 Jun 2026 13:31:18 +0200 Subject: [PATCH 2/3] Different source for Golangci-lint --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 6227c81..65910b7 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -34,7 +34,7 @@ jobs: - run: name: Lint command: | - curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v2.12.2 + curl -sSfL https://golangci-lint.run/install.sh | sh -s -- -b $(go env GOPATH)/bin v2.12.2 golangci-lint run - run: From cef44bb680eb7139910b5c4e85f8b352251c50d9 Mon Sep 17 00:00:00 2001 From: Mark van der Velden Date: Wed, 24 Jun 2026 13:42:13 +0200 Subject: [PATCH 3/3] Linter updates --- .golangci.toml | 91 +++++++++++++++++++++++++++----------------- cmd/web/main.go | 1 - finder/find.go | 2 +- keyboard/distance.go | 2 + 4 files changed, 60 insertions(+), 36 deletions(-) diff --git a/.golangci.toml b/.golangci.toml index 6738aba..bec82ae 100644 --- a/.golangci.toml +++ b/.golangci.toml @@ -1,44 +1,67 @@ +version = '2' + [run] concurrency = 4 tests = false -[linters-settings] - [linters-settings.gocognit] - min-complexity = 20 +[linters] + default = 'none' + enable = [ + #'depguard', + 'errcheck', + 'exhaustive', + 'gocognit', + 'goconst', + 'gocritic', + 'gosec', + 'govet', + 'ineffassign', + 'misspell', + 'prealloc', + 'staticcheck', + 'unconvert', + 'unparam', + 'unused' + ] + + [linters.settings] + [linters.settings.gocognit] + min-complexity = 20 - [linters-settings.gofumpt] - lang-version = "1.19" - extra-rules = true + [linters.settings.goconst] + min-len = 2 + min-occurrences = 2 - [linters-settings.goconst] - min-len = 2 - min-occurrences = 2 + [linters.settings.misspell] + locale = 'US' - [linters-settings.misspell] - locale = "US" + [linters.exclusions] + generated = 'lax' + presets = [ + 'comments', + 'common-false-positives', + 'legacy', + 'std-error-handling' + ] + paths = [ + 'third_party$', + 'builtin$', + 'examples$' + ] -[linters] - disable-all = true +[formatters] enable = [ - "staticcheck", - "gosimple", - "ineffassign", - "typecheck", - "govet", - "errcheck", - "unused", - "exhaustive", - - "stylecheck", - "gosec", - "unconvert", - "goconst", - "gocognit", - "depguard", - "misspell", - "unparam", - "prealloc", - "gofumpt", - "exportloopref", - "gocritic", + 'gofumpt' ] + + [formatters.settings] + [formatters.settings.gofumpt] + extra-rules = true + + [formatters.exclusions] + generated = 'lax' + paths = [ + 'third_party$', + 'builtin$', + 'examples$' + ] diff --git a/cmd/web/main.go b/cmd/web/main.go index db1f38e..ee0cd1c 100644 --- a/cmd/web/main.go +++ b/cmd/web/main.go @@ -30,7 +30,6 @@ func main() { logger.Formatter = &logrus.JSONFormatter{} logger.Out = os.Stdout logger.Level, err = logrus.ParseLevel(config.Server.Log.Level) - if err != nil { panic(err) } diff --git a/finder/find.go b/finder/find.go index 90c26c4..cf39003 100644 --- a/finder/find.go +++ b/finder/find.go @@ -122,7 +122,7 @@ func (t *Finder) FindTopRankingCtx(ctx context.Context, input string) ([]string, // prefixLength cannot exceed length of input func (t *Finder) FindTopRankingPrefixCtx(ctx context.Context, input string, prefixLength uint) (list []string, exact bool, err error) { list, _, exact, err = t.findTopRankingCtx(ctx, input, prefixLength) - return + return list, exact, err } // getRefList returns the appropriate list of references. getRefList does not deal with locks! diff --git a/keyboard/distance.go b/keyboard/distance.go index bb3f571..7962a1e 100644 --- a/keyboard/distance.go +++ b/keyboard/distance.go @@ -102,6 +102,8 @@ func (kd KeyDist) CalculateDistance(input, ref string) float64 { func euclideanDistance(a, b coordinates) float64 { return math.Sqrt( + // Prevent QF1005 here. + //nolint:staticcheck math.Pow(b.X-a.X, 2) + math.Pow(b.Y-a.Y, 2), ) }